fix pp update logic to not insert multiple pps

This commit is contained in:
Christian Grothoff 2020-02-25 14:20:41 +01:00
parent 548a0cc09d
commit 47e8190e9d
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC

View File

@ -115,6 +115,10 @@ struct WireAccount
*/ */
int watch_debit; int watch_debit;
/**
* Return value when we got this account's progress point.
*/
enum GNUNET_DB_QueryStatus qsx;
}; };
@ -230,8 +234,9 @@ static struct WireAccount *wa_tail;
/** /**
* Query status for the incremental processing status in the auditordb. * Query status for the incremental processing status in the auditordb.
* Return value from our call to the "get_wire_auditor_progress" function.
*/ */
static enum GNUNET_DB_QueryStatus qsx; static enum GNUNET_DB_QueryStatus qsx_gwap;
/** /**
* Last reserve_in / wire_out serial IDs seen. * Last reserve_in / wire_out serial IDs seen.
@ -798,7 +803,7 @@ commit (enum GNUNET_DB_QueryStatus qs)
last_wire_out_serial_id last_wire_out_serial_id
)) ))
); );
if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qsx) if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == wa->qsx)
qs = adb->update_wire_auditor_account_progress (adb->cls, qs = adb->update_wire_auditor_account_progress (adb->cls,
asession, asession,
&master_pub, &master_pub,
@ -825,7 +830,7 @@ commit (enum GNUNET_DB_QueryStatus qs)
GNUNET_CONTAINER_multihashmap_iterate (reserve_closures, GNUNET_CONTAINER_multihashmap_iterate (reserve_closures,
&check_pending_rc, &check_pending_rc,
NULL); NULL);
if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qsx) if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qsx_gwap)
qs = adb->update_wire_auditor_progress (adb->cls, qs = adb->update_wire_auditor_progress (adb->cls,
asession, asession,
&master_pub, &master_pub,
@ -1965,7 +1970,6 @@ reserve_closed_cb (void *cls,
static void static void
begin_transaction () begin_transaction ()
{ {
enum GNUNET_DB_QueryStatus qsx;
int ret; int ret;
ret = adb->start (adb->cls, ret = adb->start (adb->cls,
@ -1993,14 +1997,14 @@ begin_transaction ()
NULL != wa; NULL != wa;
wa = wa->next) wa = wa->next)
{ {
qsx = adb->get_wire_auditor_account_progress (adb->cls, wa->qsx = adb->get_wire_auditor_account_progress (adb->cls,
asession, asession,
&master_pub, &master_pub,
wa->section_name, wa->section_name,
&wa->pp, &wa->pp,
&wa->in_wire_off, &wa->in_wire_off,
&wa->out_wire_off); &wa->out_wire_off);
if (0 > qsx) if (0 > wa->qsx)
{ {
GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qsx); GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qsx);
global_ret = 1; global_ret = 1;
@ -2009,18 +2013,18 @@ begin_transaction ()
} }
wa->start_pp = wa->pp; wa->start_pp = wa->pp;
} }
qsx = adb->get_wire_auditor_progress (adb->cls, qsx_gwap = adb->get_wire_auditor_progress (adb->cls,
asession, asession,
&master_pub, &master_pub,
&pp); &pp);
if (0 > qsx) if (0 > qsx_gwap)
{ {
GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qsx); GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qsx_gwap);
global_ret = 1; global_ret = 1;
GNUNET_SCHEDULER_shutdown (); GNUNET_SCHEDULER_shutdown ();
return; return;
} }
if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qsx) if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qsx_gwap)
{ {
GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
_ ( _ (
@ -2034,18 +2038,23 @@ begin_transaction ()
GNUNET_STRINGS_absolute_time_to_string (pp.last_timestamp), GNUNET_STRINGS_absolute_time_to_string (pp.last_timestamp),
(unsigned long long) pp.last_reserve_close_uuid); (unsigned long long) pp.last_reserve_close_uuid);
} }
qsx = edb->select_reserve_closed_above_serial_id (edb->cls,
esession,
pp.
last_reserve_close_uuid,
&reserve_closed_cb,
NULL);
if (0 > qsx)
{ {
GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR == qsx); enum GNUNET_DB_QueryStatus qs;
global_ret = 1;
GNUNET_SCHEDULER_shutdown (); qs = edb->select_reserve_closed_above_serial_id (edb->cls,
return; esession,
pp.
last_reserve_close_uuid,
&reserve_closed_cb,
NULL);
if (0 > qs)
{
GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR == qs);
global_ret = 1;
GNUNET_SCHEDULER_shutdown ();
return;
}
} }
begin_credit_audit (); begin_credit_audit ();
} }