add -r command line option to wirewatch

This commit is contained in:
Christian Grothoff 2017-12-10 19:15:15 +01:00
parent 749c02fe37
commit 0b9ffa874f
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC
2 changed files with 34 additions and 19 deletions

View File

@ -22,6 +22,9 @@ Print short help on options.
.IP "\-T, \-\-test" .IP "\-T, \-\-test"
Run in test mode and exit when idle. Run in test mode and exit when idle.
.B .B
.IP "\-r, \-\-reset"
Ignore our own database and start with transactions from the beginning of time.
.B
.IP "\-v, \-\-version" .IP "\-v, \-\-version"
Print version information. Print version information.
.B .B

View File

@ -116,6 +116,11 @@ static int delay;
*/ */
static int test_mode; static int test_mode;
/**
* Are we running from scratch and should re-process all transactions?
*/
static int reset_mode;
/** /**
* Next task to run, if any. * Next task to run, if any.
*/ */
@ -443,26 +448,29 @@ find_transfers (void *cls)
GNUNET_SCHEDULER_shutdown (); GNUNET_SCHEDULER_shutdown ();
return; return;
} }
qs = db_plugin->get_latest_reserve_in_reference (db_plugin->cls, if (! reset_mode)
session,
&start_off,
&start_off_size);
if (GNUNET_DB_STATUS_HARD_ERROR == qs)
{ {
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, qs = db_plugin->get_latest_reserve_in_reference (db_plugin->cls,
"Failed to obtain starting point for montoring from database!\n"); session,
global_ret = GNUNET_SYSERR; &start_off,
GNUNET_SCHEDULER_shutdown (); &start_off_size);
return; if (GNUNET_DB_STATUS_HARD_ERROR == qs)
} {
if (GNUNET_DB_STATUS_SOFT_ERROR == qs) GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
{ "Failed to obtain starting point for montoring from database!\n");
/* try again */ global_ret = GNUNET_SYSERR;
db_plugin->rollback (db_plugin->cls, GNUNET_SCHEDULER_shutdown ();
session); return;
task = GNUNET_SCHEDULER_add_now (&find_transfers, }
NULL); if (GNUNET_DB_STATUS_SOFT_ERROR == qs)
return; {
/* try again */
db_plugin->rollback (db_plugin->cls,
session);
task = GNUNET_SCHEDULER_add_now (&find_transfers,
NULL);
return;
}
} }
delay = GNUNET_YES; delay = GNUNET_YES;
hh = wire_plugin->get_history (wire_plugin->cls, hh = wire_plugin->get_history (wire_plugin->cls,
@ -535,6 +543,10 @@ main (int argc,
"test", "test",
"run in test mode and exit when idle", "run in test mode and exit when idle",
&test_mode), &test_mode),
GNUNET_GETOPT_option_flag ('r',
"reset",
"start fresh with all transactions in the history",
&reset_mode),
GNUNET_GETOPT_OPTION_END GNUNET_GETOPT_OPTION_END
}; };