simple error handling issues, update TODO/plan

This commit is contained in:
Christian Grothoff 2017-03-17 18:46:11 +01:00
parent d1d767f8dd
commit c250200f44
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC

View File

@ -22,18 +22,25 @@
* - This auditor does not verify that 'reserves_in' actually matches * - This auditor does not verify that 'reserves_in' actually matches
* the wire transfers from the bank. This needs to be checked separately! * the wire transfers from the bank. This needs to be checked separately!
* - Similarly, we do not check that the outgoing wire transfers match those * - Similarly, we do not check that the outgoing wire transfers match those
* given in the aggregation_tracking table. This needs to be checked separately! * given in the 'wire_out' (TBD!) table. This needs to be checked separately!
* *
* TODO: * TODO:
* - modify auditordb to allow multiple last serial IDs per table in progress tracking
* - implement coin/denomination audit
* - implement merchant deposit audit * - implement merchant deposit audit
* - see if we need more tables there * => we need a 'wire_out' table here (amount, h-wire, date, wtid)
* - modify auditordb to allow multiple last serial IDs per table in progress tracking
* - modify auditordb to track risk with balances and fees
* - modify auditordb to return DK when we inquire about deposit/refresh/refund,
* so we can avoid the costly #get_coin_summary with the transaction history building
* (at least during #analyze_coins); the logic may be partially useful in
* #analyze_merchants (but we won't need the cache!)
* - deal with risk / expired denomination keys in #sync_denomination
* - write reporting logic to output nice report beyond GNUNET_log() * - write reporting logic to output nice report beyond GNUNET_log()
* - write logic to deal with emergency (#3887) -- and emergency-related tables!
* *
* EXTERNAL: * EXTERNAL:
* - add tool to pay-back expired reserves (#4956), and support here * - add tool to pay-back expired reserves (#4956), and support here
* - add tool to verify 'reserves_in' from wire transfer inspection * - add tool to verify 'reserves_in' from wire transfer inspection
* - add tool to verify 'wire_out (TBD)' from wire transfer inspection
* - add tool to trigger computation of historic revenues * - add tool to trigger computation of historic revenues
* (move balances from 'current' revenue/profits to 'historic' tables) * (move balances from 'current' revenue/profits to 'historic' tables)
*/ */
@ -1065,6 +1072,11 @@ struct CoinContext
*/ */
unsigned int summaries_off; unsigned int summaries_off;
/**
* #GNUNET_OK as long as we are fine to commit the result to the #adb.
*/
int ret;
}; };
@ -1160,10 +1172,8 @@ sync_denomination (void *cls,
struct DenominationSummary *ds = value; struct DenominationSummary *ds = value;
int ret; int ret;
// FIXME: if expired, insert into historic denomination revenue // FIXME: if expired, insert remaining balance historic denomination revenue,
// and DELETE denomination balance. // DELETE denomination balance, and REDUCE cc->risk exposure!
// FIXME: update "global" info about denominations (here?)
if (ds->in_db) if (ds->in_db)
ret = adb->update_denomination_balance (adb->cls, ret = adb->update_denomination_balance (adb->cls,
@ -1183,9 +1193,11 @@ sync_denomination (void *cls,
ds->last_deposit_serial_id, ds->last_deposit_serial_id,
ds->last_melt_serial_id, ds->last_melt_serial_id,
ds->last_refund_serial_id); ds->last_refund_serial_id);
if (GNUNET_OK != ret)
// FIXME handle errors in 'ret' {
GNUNET_break (0);
cc.ret = GNUNET_SYSERR;
}
GNUNET_assert (GNUNET_YES == GNUNET_assert (GNUNET_YES ==
GNUNET_CONTAINER_multihashmap_remove (cc->denominations, GNUNET_CONTAINER_multihashmap_remove (cc->denominations,
denom_hash, denom_hash,
@ -1944,6 +1956,7 @@ analyze_coins (void *cls)
int rret; int rret;
/* setup 'cc' */ /* setup 'cc' */
cc.ret = GNUNET_OK;
// FIXME: FIX misnomer "denomination_summary", as this is no longer exactly about denominations! // FIXME: FIX misnomer "denomination_summary", as this is no longer exactly about denominations!
// FIXME: combine request with the one for the 'risk' summary? // FIXME: combine request with the one for the 'risk' summary?
dret = adb->get_denomination_summary (adb->cls, dret = adb->get_denomination_summary (adb->cls,
@ -2002,7 +2015,8 @@ analyze_coins (void *cls)
&withdraw_cb, &withdraw_cb,
&cc)) &cc))
{ {
// FIXME... GNUNET_break (0);
return GNUNET_SYSERR;
} }
/* process refreshs */ /* process refreshs */
@ -2013,7 +2027,8 @@ analyze_coins (void *cls)
&refresh_session_cb, &refresh_session_cb,
&cc)) &cc))
{ {
// FIXME... GNUNET_break (0);
return GNUNET_SYSERR;
} }
/* process deposits */ /* process deposits */
@ -2024,7 +2039,8 @@ analyze_coins (void *cls)
&deposit_cb, &deposit_cb,
&cc)) &cc))
{ {
// FIXME... GNUNET_break (0);
return GNUNET_SYSERR;
} }
/* process refunds */ /* process refunds */
@ -2035,13 +2051,10 @@ analyze_coins (void *cls)
&refund_cb, &refund_cb,
&cc)) &cc))
{ {
// FIXME... GNUNET_break (0);
return GNUNET_SYSERR;
} }
// FIXME...
/* FIXME: check invariants */
/* sync 'cc' back to disk */ /* sync 'cc' back to disk */
GNUNET_CONTAINER_multihashmap_iterate (cc.denominations, GNUNET_CONTAINER_multihashmap_iterate (cc.denominations,
&sync_denomination, &sync_denomination,
@ -2062,9 +2075,14 @@ analyze_coins (void *cls)
asession, asession,
&master_pub, &master_pub,
&cc.risk); &cc.risk);
// FIXME: handle error in 'rret'! if (GNUNET_OK != rret)
{
GNUNET_break (0);
return GNUNET_SYSERR;
}
// FIXME: FIX misnomer "denomination_summary", as this is no longer about denominations! // FIXME: FIX misnomer "denomination_summary", as this is no longer about denominations!
// FIXME: maybe combine with 'risk' above...
if (GNUNET_YES == dret) if (GNUNET_YES == dret)
dret = adb->update_denomination_summary (adb->cls, dret = adb->update_denomination_summary (adb->cls,
asession, asession,
@ -2081,8 +2099,13 @@ analyze_coins (void *cls)
&cc.deposit_fee_balance, &cc.deposit_fee_balance,
&cc.melt_fee_balance, &cc.melt_fee_balance,
&cc.refund_fee_balance); &cc.refund_fee_balance);
// FIXME: handle error in 'dret'! if (GNUNET_OK != dret)
return GNUNET_OK; {
GNUNET_break (0);
return GNUNET_SYSERR;
}
return cc.ret;
} }
@ -2261,50 +2284,50 @@ transact (Analysis analysis,
ret = adb->start (adb->cls, ret = adb->start (adb->cls,
asession); asession);
if (GNUNET_OK != ret) if (GNUNET_OK != ret)
{ {
GNUNET_break (0); GNUNET_break (0);
return GNUNET_SYSERR; return GNUNET_SYSERR;
} }
ret = edb->start (edb->cls, ret = edb->start (edb->cls,
esession); esession);
if (GNUNET_OK != ret) if (GNUNET_OK != ret)
{ {
GNUNET_break (0); GNUNET_break (0);
return GNUNET_SYSERR; return GNUNET_SYSERR;
} }
ret = incremental_processing (analysis, ret = incremental_processing (analysis,
analysis_cls); analysis_cls);
if (GNUNET_OK == ret) if (GNUNET_OK == ret)
{ {
ret = edb->commit (edb->cls, ret = edb->commit (edb->cls,
esession); esession);
if (GNUNET_OK != ret) if (GNUNET_OK != ret)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Exchange DB commit failed, rolling back transaction\n");
adb->rollback (adb->cls,
asession);
}
else
{
ret = adb->commit (adb->cls,
asession);
if (GNUNET_OK != ret)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Auditor DB commit failed!\n");
}
}
}
else
{ {
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Processing failed, rolling back transaction\n"); "Exchange DB commit failed, rolling back transaction\n");
adb->rollback (adb->cls, adb->rollback (adb->cls,
asession); asession);
edb->rollback (edb->cls,
esession);
} }
else
{
ret = adb->commit (adb->cls,
asession);
if (GNUNET_OK != ret)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Auditor DB commit failed!\n");
}
}
}
else
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Processing failed, rolling back transaction\n");
adb->rollback (adb->cls,
asession);
edb->rollback (edb->cls,
esession);
}
clear_transaction_state_cache (); clear_transaction_state_cache ();
return ret; return ret;
} }