diff options
Diffstat (limited to 'src/auditor/taler-helper-auditor-reserves.c')
-rw-r--r-- | src/auditor/taler-helper-auditor-reserves.c | 436 |
1 files changed, 225 insertions, 211 deletions
diff --git a/src/auditor/taler-helper-auditor-reserves.c b/src/auditor/taler-helper-auditor-reserves.c index 06c727056..aa35c6a75 100644 --- a/src/auditor/taler-helper-auditor-reserves.c +++ b/src/auditor/taler-helper-auditor-reserves.c @@ -39,6 +39,14 @@ static int global_ret; /** + * Run in test mode. Exit when idle instead of + * going to sleep and waiting for more work. + * + * FIXME: not yet implemented! + */ +static int test_mode; + +/** * After how long should idle reserves be closed? */ static struct GNUNET_TIME_Relative idle_reserve_expiration_time; @@ -46,15 +54,29 @@ static struct GNUNET_TIME_Relative idle_reserve_expiration_time; /** * Checkpointing our progress for reserves. */ -static struct TALER_AUDITORDB_ProgressPointReserve ppr; +static TALER_ARL_DEF_PP (reserves_reserve_in_serial_id); +static TALER_ARL_DEF_PP (reserves_reserve_out_serial_id); +static TALER_ARL_DEF_PP (reserves_reserve_recoup_serial_id); +static TALER_ARL_DEF_PP (reserves_reserve_open_serial_id); +static TALER_ARL_DEF_PP (reserves_reserve_close_serial_id); +static TALER_ARL_DEF_PP (reserves_purse_decisions_serial_id); +static TALER_ARL_DEF_PP (reserves_account_merges_serial_id); +static TALER_ARL_DEF_PP (reserves_history_requests_serial_id); /** - * Checkpointing our progress for reserves. + * Tracked global reserve balances. */ -static struct TALER_AUDITORDB_ProgressPointReserve ppr_start; +static TALER_ARL_DEF_AB (reserves_reserve_total_balance); +static TALER_ARL_DEF_AB (reserves_reserve_loss); +static TALER_ARL_DEF_AB (reserves_withdraw_fee_revenue); +static TALER_ARL_DEF_AB (reserves_close_fee_revenue); +static TALER_ARL_DEF_AB (reserves_purse_fee_revenue); +static TALER_ARL_DEF_AB (reserves_open_fee_revenue); +static TALER_ARL_DEF_AB (reserves_history_fee_revenue); + /** - * Array of reports about row inconsitencies. + * Array of reports about row inconsistencies. */ static json_t *report_row_inconsistencies; @@ -65,12 +87,12 @@ static json_t *report_row_inconsistencies; static json_t *denomination_key_validity_withdraw_inconsistencies; /** - * Array of reports about reserve balance insufficient inconsitencies. + * Array of reports about reserve balance insufficient inconsistencies. */ static json_t *report_reserve_balance_insufficient_inconsistencies; /** - * Array of reports about purse balance insufficient inconsitencies. + * Array of reports about purse balance insufficient inconsistencies. */ static json_t *report_purse_balance_insufficient_inconsistencies; @@ -94,7 +116,7 @@ static struct TALER_Amount total_balance_summary_delta_plus; static struct TALER_Amount total_balance_summary_delta_minus; /** - * Array of reports about reserve's not being closed inconsitencies. + * Array of reports about reserve's not being closed inconsistencies. */ static json_t *report_reserve_not_closed_inconsistencies; @@ -120,11 +142,6 @@ static struct TALER_Amount total_arithmetic_delta_plus; static struct TALER_Amount total_arithmetic_delta_minus; /** - * Expected reserve balances. - */ -static struct TALER_AUDITORDB_ReserveFeeBalance balance; - -/** * Array of reports about coin operations with bad signatures. */ static json_t *report_bad_sig_losses; @@ -304,7 +321,6 @@ load_auditor_reserve_summary (struct ReserveSummary *rs) qs = TALER_ARL_adb->get_reserve_info (TALER_ARL_adb->cls, &rs->reserve_pub, - &TALER_ARL_master_pub, &rowid, &rs->prev_balance, &rs->a_expiration_date, @@ -471,8 +487,8 @@ handle_reserve_in (void *cls, (void) wire_reference; /* should be monotonically increasing */ - GNUNET_assert (rowid >= ppr.last_reserve_in_serial_id); - ppr.last_reserve_in_serial_id = rowid + 1; + GNUNET_assert (rowid >= TALER_ARL_USE_PP (reserves_reserve_in_serial_id)); + TALER_ARL_USE_PP (reserves_reserve_in_serial_id) = rowid + 1; rs = setup_reserve (rc, reserve_pub); if (NULL == rs) @@ -532,8 +548,8 @@ handle_reserve_out (void *cls, struct TALER_DenominationHashP h_denom_pub; /* should be monotonically increasing */ - GNUNET_assert (rowid >= ppr.last_reserve_out_serial_id); - ppr.last_reserve_out_serial_id = rowid + 1; + GNUNET_assert (rowid >= TALER_ARL_USE_PP (reserves_reserve_out_serial_id)); + TALER_ARL_USE_PP (reserves_reserve_out_serial_id) = rowid + 1; /* lookup denomination pub data (make sure denom_pub is valid, establish fees); initializes wsrd.h_denomination_pub! */ @@ -640,8 +656,8 @@ handle_reserve_out (void *cls, TALER_ARL_amount_add (&rs->curr_balance.withdraw_fee_balance, &rs->curr_balance.withdraw_fee_balance, &issue->fees.withdraw); - TALER_ARL_amount_add (&balance.withdraw_fee_balance, - &balance.withdraw_fee_balance, + TALER_ARL_amount_add (&TALER_ARL_USE_AB (reserves_withdraw_fee_revenue), + &TALER_ARL_USE_AB (reserves_withdraw_fee_revenue), &issue->fees.withdraw); TALER_ARL_amount_add (&rs->total_out, &rs->total_out, @@ -678,7 +694,7 @@ handle_recoup_by_reserve ( const struct TALER_CoinPublicInfo *coin, const struct TALER_DenominationPublicKey *denom_pub, const struct TALER_CoinSpendSignatureP *coin_sig, - const union TALER_DenominationBlindingKeyP *coin_blind) + const union GNUNET_CRYPTO_BlindingSecretP *coin_blind) { struct ReserveContext *rc = cls; struct ReserveSummary *rs; @@ -690,8 +706,8 @@ handle_recoup_by_reserve ( (void) denom_pub; /* should be monotonically increasing */ - GNUNET_assert (rowid >= ppr.last_reserve_recoup_serial_id); - ppr.last_reserve_recoup_serial_id = rowid + 1; + GNUNET_assert (rowid >= TALER_ARL_USE_PP (reserves_reserve_recoup_serial_id)); + TALER_ARL_USE_PP (reserves_reserve_recoup_serial_id) = rowid + 1; /* We know that denom_pub matches denom_pub_hash because this is how the SQL statement joined the tables. */ if (GNUNET_OK != @@ -735,8 +751,8 @@ handle_recoup_by_reserve ( report_row_inconsistency ("recoup", rowid, "denomination key not in revocation set"); - TALER_ARL_amount_add (&balance.reserve_loss, - &balance.reserve_loss, + TALER_ARL_amount_add (&TALER_ARL_USE_AB (reserves_reserve_loss), + &TALER_ARL_USE_AB (reserves_reserve_loss), amount); } else @@ -892,8 +908,8 @@ handle_reserve_open ( struct ReserveSummary *rs; /* should be monotonically increasing */ - GNUNET_assert (rowid >= ppr.last_reserve_open_serial_id); - ppr.last_reserve_open_serial_id = rowid + 1; + GNUNET_assert (rowid >= TALER_ARL_USE_PP (reserves_reserve_open_serial_id)); + TALER_ARL_USE_PP (reserves_reserve_open_serial_id) = rowid + 1; rs = setup_reserve (rc, reserve_pub); @@ -928,8 +944,8 @@ handle_reserve_open ( TALER_ARL_amount_add (&rs->curr_balance.open_fee_balance, &rs->curr_balance.open_fee_balance, reserve_payment); - TALER_ARL_amount_add (&balance.open_fee_balance, - &balance.open_fee_balance, + TALER_ARL_amount_add (&TALER_ARL_USE_AB (reserves_open_fee_revenue), + &TALER_ARL_USE_AB (reserves_open_fee_revenue), reserve_payment); TALER_ARL_amount_add (&rs->total_out, &rs->total_out, @@ -977,8 +993,8 @@ handle_reserve_closed ( (void) transfer_details; /* should be monotonically increasing */ - GNUNET_assert (rowid >= ppr.last_reserve_close_serial_id); - ppr.last_reserve_close_serial_id = rowid + 1; + GNUNET_assert (rowid >= TALER_ARL_USE_PP (reserves_reserve_close_serial_id)); + TALER_ARL_USE_PP (reserves_reserve_close_serial_id) = rowid + 1; rs = setup_reserve (rc, reserve_pub); @@ -1013,8 +1029,8 @@ handle_reserve_closed ( TALER_ARL_amount_add (&rs->curr_balance.close_fee_balance, &rs->curr_balance.close_fee_balance, closing_fee); - TALER_ARL_amount_add (&balance.close_fee_balance, - &balance.close_fee_balance, + TALER_ARL_amount_add (&TALER_ARL_USE_AB (reserves_close_fee_revenue), + &TALER_ARL_USE_AB (reserves_close_fee_revenue), closing_fee); TALER_ARL_amount_add (&rs->total_out, &rs->total_out, @@ -1081,8 +1097,9 @@ handle_reserve_closed ( } if (NULL == payto_uri) { - if (0 != strcmp (rs->sender_account, - receiver_account)) + if ( (NULL == rs->sender_account) || + (0 != strcmp (rs->sender_account, + receiver_account)) ) { report_row_inconsistency ("reserves_close", rowid, @@ -1110,8 +1127,8 @@ handle_reserve_closed ( rowid, "target account not verified, auditor does not know reserve"); } - if (0 != strcmp (rs->sender_account, - receiver_account)) + else if (0 != strcmp (rs->sender_account, + receiver_account)) { report_row_inconsistency ("reserves_close", rowid, @@ -1167,8 +1184,8 @@ handle_account_merged ( struct ReserveSummary *rs; /* should be monotonically increasing */ - GNUNET_assert (rowid >= ppr.last_account_merges_serial_id); - ppr.last_account_merges_serial_id = rowid + 1; + GNUNET_assert (rowid >= TALER_ARL_USE_PP (reserves_account_merges_serial_id)); + TALER_ARL_USE_PP (reserves_account_merges_serial_id) = rowid + 1; if (GNUNET_OK != TALER_wallet_account_merge_verify (merge_timestamp, purse_pub, @@ -1206,8 +1223,8 @@ handle_account_merged ( GNUNET_break (0); return GNUNET_SYSERR; } - TALER_ARL_amount_add (&balance.purse_fee_balance, - &balance.purse_fee_balance, + TALER_ARL_amount_add (&TALER_ARL_USE_AB (reserves_purse_fee_revenue), + &TALER_ARL_USE_AB (reserves_purse_fee_revenue), purse_fee); TALER_ARL_amount_add (&rs->curr_balance.purse_fee_balance, &rs->curr_balance.purse_fee_balance, @@ -1241,8 +1258,9 @@ purse_decision_cb (void *cls, struct ReserveContext *rc = cls; struct ReserveSummary *rs; - GNUNET_assert (rowid >= ppr.last_purse_decisions_serial_id); /* should be monotonically increasing */ - ppr.last_purse_decisions_serial_id = rowid + 1; + GNUNET_assert (rowid >= TALER_ARL_USE_PP ( + reserves_purse_decisions_serial_id)); /* should be monotonically increasing */ + TALER_ARL_USE_PP (reserves_purse_decisions_serial_id) = rowid + 1; rs = setup_reserve (rc, reserve_pub); if (NULL == rs) @@ -1260,75 +1278,6 @@ purse_decision_cb (void *cls, /** - * Function called with details about - * history requests that have been made, with - * the goal of auditing the history request execution. - * - * @param cls closure - * @param rowid unique serial ID for the deposit in our DB - * @param history_fee fee paid for the request - * @param ts timestamp of the request - * @param reserve_pub reserve history was requested for - * @param reserve_sig signature approving the @a history_fee - * @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop - */ -static enum GNUNET_GenericReturnValue -handle_history_request ( - void *cls, - uint64_t rowid, - const struct TALER_Amount *history_fee, - const struct GNUNET_TIME_Timestamp ts, - const struct TALER_ReservePublicKeyP *reserve_pub, - const struct TALER_ReserveSignatureP *reserve_sig) -{ - struct ReserveContext *rc = cls; - struct ReserveSummary *rs; - - /* should be monotonically increasing */ - GNUNET_assert (rowid >= ppr.last_history_requests_serial_id); - ppr.last_history_requests_serial_id = rowid + 1; - if (GNUNET_OK != - TALER_wallet_reserve_history_verify (ts, - history_fee, - reserve_pub, - reserve_sig)) - { - TALER_ARL_report (report_bad_sig_losses, - GNUNET_JSON_PACK ( - GNUNET_JSON_pack_string ("operation", - "account-history"), - GNUNET_JSON_pack_uint64 ("row", - rowid), - TALER_JSON_pack_amount ("loss", - history_fee), - GNUNET_JSON_pack_data_auto ("key_pub", - reserve_pub))); - TALER_ARL_amount_add (&total_bad_sig_loss, - &total_bad_sig_loss, - history_fee); - return GNUNET_OK; - } - rs = setup_reserve (rc, - reserve_pub); - if (NULL == rs) - { - GNUNET_break (0); - return GNUNET_SYSERR; - } - TALER_ARL_amount_add (&balance.history_fee_balance, - &balance.history_fee_balance, - history_fee); - TALER_ARL_amount_add (&rs->curr_balance.history_fee_balance, - &rs->curr_balance.history_fee_balance, - history_fee); - TALER_ARL_amount_add (&rs->total_out, - &rs->total_out, - history_fee); - return GNUNET_OK; -} - - -/** * Check that the reserve summary matches what the exchange database * thinks about the reserve, and update our own state of the reserve. * @@ -1370,8 +1319,8 @@ verify_reserve_balance (void *cls, TALER_ARL_amount_add (&rs->curr_balance.reserve_loss, &rs->prev_balance.reserve_loss, &loss); - TALER_ARL_amount_add (&balance.reserve_loss, - &balance.reserve_loss, + TALER_ARL_amount_add (&TALER_ARL_USE_AB (reserves_reserve_loss), + &TALER_ARL_USE_AB (reserves_reserve_loss), &loss); TALER_ARL_report (report_reserve_balance_insufficient_inconsistencies, GNUNET_JSON_PACK ( @@ -1546,15 +1495,16 @@ verify_reserve_balance (void *cls, /* Update global balance: add incoming first, then try to subtract outgoing... */ - TALER_ARL_amount_add (&balance.reserve_balance, - &balance.reserve_balance, + TALER_ARL_amount_add (&TALER_ARL_USE_AB (reserves_reserve_total_balance), + &TALER_ARL_USE_AB (reserves_reserve_total_balance), &rs->total_in); { struct TALER_Amount r; if (TALER_ARL_SR_INVALID_NEGATIVE == TALER_ARL_amount_subtract_neg (&r, - &balance.reserve_balance, + &TALER_ARL_USE_AB ( + reserves_reserve_total_balance), &rs->total_out)) { /* We could not reduce our total balance, i.e. exchange allowed IN TOTAL (!) @@ -1562,18 +1512,20 @@ verify_reserve_balance (void *cls, went negative!). Woopsie. Calculate how badly it went and log. */ report_amount_arithmetic_inconsistency ("global escrow balance", 0, - &balance.reserve_balance, /* what we had */ + &TALER_ARL_USE_AB ( + reserves_reserve_total_balance), /* what we had */ &rs->total_out, /* what we needed */ 0 /* specific profit/loss does not apply to the total summary */); /* We unexpectedly went negative, so a sane value to continue from would be zero. */ GNUNET_assert (GNUNET_OK == TALER_amount_set_zero (TALER_ARL_currency, - &balance.reserve_balance)); + &TALER_ARL_USE_AB ( + reserves_reserve_total_balance))); } else { - balance.reserve_balance = r; + TALER_ARL_USE_AB (reserves_reserve_total_balance) = r; } } @@ -1586,8 +1538,7 @@ verify_reserve_balance (void *cls, "Final balance of reserve `%s' is zero, dropping it\n", TALER_B2S (&rs->reserve_pub)); qs = TALER_ARL_adb->del_reserve_info (TALER_ARL_adb->cls, - &rs->reserve_pub, - &TALER_ARL_master_pub); + &rs->reserve_pub); if (0 >= qs) { GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); @@ -1612,13 +1563,11 @@ verify_reserve_balance (void *cls, if (rs->had_ri) qs = TALER_ARL_adb->update_reserve_info (TALER_ARL_adb->cls, &rs->reserve_pub, - &TALER_ARL_master_pub, &rs->prev_balance, rs->a_expiration_date); else qs = TALER_ARL_adb->insert_reserve_info (TALER_ARL_adb->cls, &rs->reserve_pub, - &TALER_ARL_master_pub, &rs->prev_balance, rs->a_expiration_date, rs->sender_account); @@ -1657,9 +1606,17 @@ analyze_reserves (void *cls) (void) cls; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Analyzing reserves\n"); - qsp = TALER_ARL_adb->get_auditor_progress_reserve (TALER_ARL_adb->cls, - &TALER_ARL_master_pub, - &ppr); + qsp = TALER_ARL_adb->get_auditor_progress ( + TALER_ARL_adb->cls, + TALER_ARL_GET_PP (reserves_reserve_in_serial_id), + TALER_ARL_GET_PP (reserves_reserve_out_serial_id), + TALER_ARL_GET_PP (reserves_reserve_recoup_serial_id), + TALER_ARL_GET_PP (reserves_reserve_open_serial_id), + TALER_ARL_GET_PP (reserves_reserve_close_serial_id), + TALER_ARL_GET_PP (reserves_purse_decisions_serial_id), + TALER_ARL_GET_PP (reserves_account_merges_serial_id), + TALER_ARL_GET_PP (reserves_history_requests_serial_id), + NULL); if (0 > qsp) { GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qsp); @@ -1672,22 +1629,36 @@ analyze_reserves (void *cls) } else { - ppr_start = ppr; GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Resuming reserve audit at %llu/%llu/%llu/%llu/%llu/%llu/%llu/%llu\n", - (unsigned long long) ppr.last_reserve_in_serial_id, - (unsigned long long) ppr.last_reserve_out_serial_id, - (unsigned long long) ppr.last_reserve_recoup_serial_id, - (unsigned long long) ppr.last_reserve_open_serial_id, - (unsigned long long) ppr.last_reserve_close_serial_id, - (unsigned long long) ppr.last_purse_decisions_serial_id, - (unsigned long long) ppr.last_account_merges_serial_id, - (unsigned long long) ppr.last_history_requests_serial_id); + (unsigned long long) TALER_ARL_USE_PP ( + reserves_reserve_in_serial_id), + (unsigned long long) TALER_ARL_USE_PP ( + reserves_reserve_out_serial_id), + (unsigned long long) TALER_ARL_USE_PP ( + reserves_reserve_recoup_serial_id), + (unsigned long long) TALER_ARL_USE_PP ( + reserves_reserve_open_serial_id), + (unsigned long long) TALER_ARL_USE_PP ( + reserves_reserve_close_serial_id), + (unsigned long long) TALER_ARL_USE_PP ( + reserves_purse_decisions_serial_id), + (unsigned long long) TALER_ARL_USE_PP ( + reserves_account_merges_serial_id), + (unsigned long long) TALER_ARL_USE_PP ( + reserves_history_requests_serial_id)); } rc.qs = GNUNET_DB_STATUS_SUCCESS_ONE_RESULT; - qsx = TALER_ARL_adb->get_reserve_summary (TALER_ARL_adb->cls, - &TALER_ARL_master_pub, - &balance); + qsx = TALER_ARL_adb->get_balance ( + TALER_ARL_adb->cls, + TALER_ARL_GET_AB (reserves_reserve_total_balance), + TALER_ARL_GET_AB (reserves_reserve_loss), + TALER_ARL_GET_AB (reserves_withdraw_fee_revenue), + TALER_ARL_GET_AB (reserves_close_fee_revenue), + TALER_ARL_GET_AB (reserves_purse_fee_revenue), + TALER_ARL_GET_AB (reserves_open_fee_revenue), + TALER_ARL_GET_AB (reserves_history_fee_revenue), + NULL); if (qsx < 0) { GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qsx); @@ -1699,7 +1670,7 @@ analyze_reserves (void *cls) GNUNET_NO); qs = TALER_ARL_edb->select_reserves_in_above_serial_id ( TALER_ARL_edb->cls, - ppr.last_reserve_in_serial_id, + TALER_ARL_USE_PP (reserves_reserve_in_serial_id), &handle_reserve_in, &rc); if (qs < 0) @@ -1709,7 +1680,7 @@ analyze_reserves (void *cls) } qs = TALER_ARL_edb->select_withdrawals_above_serial_id ( TALER_ARL_edb->cls, - ppr.last_reserve_out_serial_id, + TALER_ARL_USE_PP (reserves_reserve_out_serial_id), &handle_reserve_out, &rc); if (qs < 0) @@ -1719,7 +1690,7 @@ analyze_reserves (void *cls) } qs = TALER_ARL_edb->select_recoup_above_serial_id ( TALER_ARL_edb->cls, - ppr.last_reserve_recoup_serial_id, + TALER_ARL_USE_PP (reserves_reserve_recoup_serial_id), &handle_recoup_by_reserve, &rc); if (qs < 0) @@ -1729,7 +1700,7 @@ analyze_reserves (void *cls) } qs = TALER_ARL_edb->select_reserve_open_above_serial_id ( TALER_ARL_edb->cls, - ppr.last_reserve_open_serial_id, + TALER_ARL_USE_PP (reserves_reserve_open_serial_id), &handle_reserve_open, &rc); if (qs < 0) @@ -1739,7 +1710,7 @@ analyze_reserves (void *cls) } qs = TALER_ARL_edb->select_reserve_closed_above_serial_id ( TALER_ARL_edb->cls, - ppr.last_reserve_close_serial_id, + TALER_ARL_USE_PP (reserves_reserve_close_serial_id), &handle_reserve_closed, &rc); if (qs < 0) @@ -1751,7 +1722,7 @@ analyze_reserves (void *cls) if (0 > (qs = TALER_ARL_edb->select_purse_decisions_above_serial_id ( TALER_ARL_edb->cls, - ppr.last_purse_decisions_serial_id, + TALER_ARL_USE_PP (reserves_purse_decisions_serial_id), false, /* only go for merged purses! */ &purse_decision_cb, &rc))) @@ -1764,7 +1735,7 @@ analyze_reserves (void *cls) /* Charge purse fee! */ qs = TALER_ARL_edb->select_account_merges_above_serial_id ( TALER_ARL_edb->cls, - ppr.last_account_merges_serial_id, + TALER_ARL_USE_PP (reserves_account_merges_serial_id), &handle_account_merged, &rc); if (qs < 0) @@ -1772,17 +1743,6 @@ analyze_reserves (void *cls) GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); return qs; } - /* Charge history fee! */ - qs = TALER_ARL_edb->select_history_requests_above_serial_id ( - TALER_ARL_edb->cls, - ppr.last_history_requests_serial_id, - &handle_history_request, - &rc); - if (qs < 0) - { - GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); - return qs; - } GNUNET_CONTAINER_multihashmap_iterate (rc.reserves, &verify_reserve_balance, &rc); @@ -1794,15 +1754,29 @@ analyze_reserves (void *cls) return qs; if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qsx) { - qs = TALER_ARL_adb->insert_reserve_summary (TALER_ARL_adb->cls, - &TALER_ARL_master_pub, - &balance); + qs = TALER_ARL_adb->insert_balance ( + TALER_ARL_adb->cls, + TALER_ARL_SET_AB (reserves_reserve_total_balance), + TALER_ARL_SET_AB (reserves_reserve_loss), + TALER_ARL_SET_AB (reserves_withdraw_fee_revenue), + TALER_ARL_SET_AB (reserves_close_fee_revenue), + TALER_ARL_SET_AB (reserves_purse_fee_revenue), + TALER_ARL_SET_AB (reserves_open_fee_revenue), + TALER_ARL_SET_AB (reserves_history_fee_revenue), + NULL); } else { - qs = TALER_ARL_adb->update_reserve_summary (TALER_ARL_adb->cls, - &TALER_ARL_master_pub, - &balance); + qs = TALER_ARL_adb->update_balance ( + TALER_ARL_adb->cls, + TALER_ARL_SET_AB (reserves_reserve_total_balance), + TALER_ARL_SET_AB (reserves_reserve_loss), + TALER_ARL_SET_AB (reserves_withdraw_fee_revenue), + TALER_ARL_SET_AB (reserves_close_fee_revenue), + TALER_ARL_SET_AB (reserves_purse_fee_revenue), + TALER_ARL_SET_AB (reserves_open_fee_revenue), + TALER_ARL_SET_AB (reserves_history_fee_revenue), + NULL); } if (0 >= qs) { @@ -1810,13 +1784,29 @@ analyze_reserves (void *cls) return qs; } if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qsp) - qs = TALER_ARL_adb->update_auditor_progress_reserve (TALER_ARL_adb->cls, - &TALER_ARL_master_pub, - &ppr); + qs = TALER_ARL_adb->update_auditor_progress ( + TALER_ARL_adb->cls, + TALER_ARL_SET_PP (reserves_reserve_in_serial_id), + TALER_ARL_SET_PP (reserves_reserve_out_serial_id), + TALER_ARL_SET_PP (reserves_reserve_recoup_serial_id), + TALER_ARL_SET_PP (reserves_reserve_open_serial_id), + TALER_ARL_SET_PP (reserves_reserve_close_serial_id), + TALER_ARL_SET_PP (reserves_purse_decisions_serial_id), + TALER_ARL_SET_PP (reserves_account_merges_serial_id), + TALER_ARL_SET_PP (reserves_history_requests_serial_id), + NULL); else - qs = TALER_ARL_adb->insert_auditor_progress_reserve (TALER_ARL_adb->cls, - &TALER_ARL_master_pub, - &ppr); + qs = TALER_ARL_adb->insert_auditor_progress ( + TALER_ARL_adb->cls, + TALER_ARL_SET_PP (reserves_reserve_in_serial_id), + TALER_ARL_SET_PP (reserves_reserve_out_serial_id), + TALER_ARL_SET_PP (reserves_reserve_recoup_serial_id), + TALER_ARL_SET_PP (reserves_reserve_open_serial_id), + TALER_ARL_SET_PP (reserves_reserve_close_serial_id), + TALER_ARL_SET_PP (reserves_purse_decisions_serial_id), + TALER_ARL_SET_PP (reserves_account_merges_serial_id), + TALER_ARL_SET_PP (reserves_history_requests_serial_id), + NULL); if (0 >= qs) { GNUNET_log (GNUNET_ERROR_TYPE_INFO, @@ -1826,14 +1816,22 @@ analyze_reserves (void *cls) } GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Concluded reserve audit step at %llu/%llu/%llu/%llu/%llu/%llu/%llu/%llu\n", - (unsigned long long) ppr.last_reserve_in_serial_id, - (unsigned long long) ppr.last_reserve_out_serial_id, - (unsigned long long) ppr.last_reserve_recoup_serial_id, - (unsigned long long) ppr.last_reserve_open_serial_id, - (unsigned long long) ppr.last_reserve_close_serial_id, - (unsigned long long) ppr.last_purse_decisions_serial_id, - (unsigned long long) ppr.last_account_merges_serial_id, - (unsigned long long) ppr.last_history_requests_serial_id); + (unsigned long long) TALER_ARL_USE_PP ( + reserves_reserve_in_serial_id), + (unsigned long long) TALER_ARL_USE_PP ( + reserves_reserve_out_serial_id), + (unsigned long long) TALER_ARL_USE_PP ( + reserves_reserve_recoup_serial_id), + (unsigned long long) TALER_ARL_USE_PP ( + reserves_reserve_open_serial_id), + (unsigned long long) TALER_ARL_USE_PP ( + reserves_reserve_close_serial_id), + (unsigned long long) TALER_ARL_USE_PP ( + reserves_purse_decisions_serial_id), + (unsigned long long) TALER_ARL_USE_PP ( + reserves_account_merges_serial_id), + (unsigned long long) TALER_ARL_USE_PP ( + reserves_history_requests_serial_id)); return GNUNET_DB_STATUS_SUCCESS_ONE_RESULT; } @@ -1879,25 +1877,32 @@ run (void *cls, "Starting audit\n"); GNUNET_assert (GNUNET_OK == TALER_amount_set_zero (TALER_ARL_currency, - &balance.reserve_balance)); + &TALER_ARL_USE_AB ( + reserves_reserve_total_balance))); GNUNET_assert (GNUNET_OK == TALER_amount_set_zero (TALER_ARL_currency, - &balance.reserve_loss)); + &TALER_ARL_USE_AB ( + reserves_reserve_loss))); GNUNET_assert (GNUNET_OK == TALER_amount_set_zero (TALER_ARL_currency, - &balance.withdraw_fee_balance)); + &TALER_ARL_USE_AB ( + reserves_withdraw_fee_revenue))); GNUNET_assert (GNUNET_OK == TALER_amount_set_zero (TALER_ARL_currency, - &balance.close_fee_balance)); + &TALER_ARL_USE_AB ( + reserves_close_fee_revenue))); GNUNET_assert (GNUNET_OK == TALER_amount_set_zero (TALER_ARL_currency, - &balance.purse_fee_balance)); + &TALER_ARL_USE_AB ( + reserves_purse_fee_revenue))); GNUNET_assert (GNUNET_OK == TALER_amount_set_zero (TALER_ARL_currency, - &balance.open_fee_balance)); + &TALER_ARL_USE_AB ( + reserves_open_fee_revenue))); GNUNET_assert (GNUNET_OK == TALER_amount_set_zero (TALER_ARL_currency, - &balance.history_fee_balance)); + &TALER_ARL_USE_AB ( + reserves_history_fee_revenue))); // REVIEW: GNUNET_assert (GNUNET_OK == TALER_amount_set_zero (TALER_ARL_currency, @@ -1970,20 +1975,22 @@ run (void *cls, /* Global 'balances' */ TALER_JSON_pack_amount ("total_escrow_balance", - &balance.reserve_balance), + &TALER_ARL_USE_AB ( + reserves_reserve_total_balance)), /* Tested in test-auditor.sh #3 */ TALER_JSON_pack_amount ("total_irregular_loss", - &balance.reserve_loss), + &TALER_ARL_USE_AB (reserves_reserve_loss)), TALER_JSON_pack_amount ("total_withdraw_fee_income", - &balance.withdraw_fee_balance), + &TALER_ARL_USE_AB ( + reserves_withdraw_fee_revenue)), TALER_JSON_pack_amount ("total_close_fee_income", - &balance.close_fee_balance), + &TALER_ARL_USE_AB (reserves_close_fee_revenue)), TALER_JSON_pack_amount ("total_purse_fee_income", - &balance.purse_fee_balance), + &TALER_ARL_USE_AB (reserves_purse_fee_revenue)), TALER_JSON_pack_amount ("total_open_fee_income", - &balance.open_fee_balance), + &TALER_ARL_USE_AB (reserves_open_fee_revenue)), TALER_JSON_pack_amount ("total_history_fee_income", - &balance.history_fee_balance), + &TALER_ARL_USE_AB (reserves_history_fee_revenue)), /* Detailed report tables */ GNUNET_JSON_pack_array_steal ( @@ -2014,37 +2021,45 @@ run (void *cls, TALER_JSON_pack_time_abs_human ("auditor_end_time", GNUNET_TIME_absolute_get ()), GNUNET_JSON_pack_uint64 ("start_ppr_reserve_in_serial_id", - ppr_start.last_reserve_in_serial_id), + 0 /* no longer supported */), GNUNET_JSON_pack_uint64 ("start_ppr_reserve_out_serial_id", - ppr_start.last_reserve_out_serial_id), + 0 /* no longer supported */), GNUNET_JSON_pack_uint64 ("start_ppr_reserve_recoup_serial_id", - ppr_start.last_reserve_recoup_serial_id), + 0 /* no longer supported */), GNUNET_JSON_pack_uint64 ("start_ppr_reserve_open_serial_id", - ppr_start.last_reserve_open_serial_id), + 0 /* no longer supported */), GNUNET_JSON_pack_uint64 ("start_ppr_reserve_close_serial_id", - ppr_start.last_reserve_close_serial_id), + 0 /* no longer supported */), GNUNET_JSON_pack_uint64 ("start_ppr_purse_decisions_serial_id", - ppr_start.last_purse_decisions_serial_id), + 0 /* no longer supported */), GNUNET_JSON_pack_uint64 ("start_ppr_account_merges_serial_id", - ppr_start.last_account_merges_serial_id), + 0 /* no longer supported */), GNUNET_JSON_pack_uint64 ("start_ppr_history_requests_serial_id", - ppr_start.last_history_requests_serial_id), + 0 /* no longer supported */), GNUNET_JSON_pack_uint64 ("end_ppr_reserve_in_serial_id", - ppr.last_reserve_in_serial_id), + TALER_ARL_USE_PP ( + reserves_reserve_in_serial_id)), GNUNET_JSON_pack_uint64 ("end_ppr_reserve_out_serial_id", - ppr.last_reserve_out_serial_id), + TALER_ARL_USE_PP ( + reserves_reserve_out_serial_id)), GNUNET_JSON_pack_uint64 ("end_ppr_reserve_recoup_serial_id", - ppr.last_reserve_recoup_serial_id), + TALER_ARL_USE_PP ( + reserves_reserve_recoup_serial_id)), GNUNET_JSON_pack_uint64 ("end_ppr_reserve_open_serial_id", - ppr.last_reserve_open_serial_id), + TALER_ARL_USE_PP ( + reserves_reserve_open_serial_id)), GNUNET_JSON_pack_uint64 ("end_ppr_reserve_close_serial_id", - ppr.last_reserve_close_serial_id), + TALER_ARL_USE_PP ( + reserves_reserve_close_serial_id)), GNUNET_JSON_pack_uint64 ("end_ppr_purse_decisions_serial_id", - ppr.last_purse_decisions_serial_id), + TALER_ARL_USE_PP ( + reserves_purse_decisions_serial_id)), GNUNET_JSON_pack_uint64 ("end_ppr_account_merges_serial_id", - ppr.last_account_merges_serial_id), + TALER_ARL_USE_PP ( + reserves_account_merges_serial_id)), GNUNET_JSON_pack_uint64 ("end_ppr_history_requests_serial_id", - ppr.last_history_requests_serial_id))); + TALER_ARL_USE_PP ( + reserves_history_requests_serial_id)))); } @@ -2064,11 +2079,10 @@ main (int argc, "internal", "perform checks only applicable for exchange-internal audits", &internal_checks), - GNUNET_GETOPT_option_base32_auto ('m', - "exchange-key", - "KEY", - "public key of the exchange (Crockford base32 encoded)", - &TALER_ARL_master_pub), + GNUNET_GETOPT_option_flag ('t', + "test", + "run in test mode and exit when idle", + &test_mode), GNUNET_GETOPT_option_timetravel ('T', "timetravel"), GNUNET_GETOPT_OPTION_END |