diff options
author | Christian Grothoff <christian@grothoff.org> | 2019-09-05 10:36:14 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2019-09-05 10:36:14 +0200 |
commit | 1e685a02413b739545dfb5b677d66a327760a9df (patch) | |
tree | 5abe908a3b40f5fe25552ac39e1bb29b78e0dad2 /src/auditor/taler-wire-auditor.c | |
parent | e0979ecf5e3e55e5de80bcd4e9c15fd72c4c52ea (diff) | |
download | exchange-1e685a02413b739545dfb5b677d66a327760a9df.tar.xz |
use shorter sleep, tolerate slight execution date disagreements between exchange and bank in auditor
Diffstat (limited to 'src/auditor/taler-wire-auditor.c')
-rw-r--r-- | src/auditor/taler-wire-auditor.c | 41 |
1 files changed, 34 insertions, 7 deletions
diff --git a/src/auditor/taler-wire-auditor.c b/src/auditor/taler-wire-auditor.c index e1af48883..85638fa76 100644 --- a/src/auditor/taler-wire-auditor.c +++ b/src/auditor/taler-wire-auditor.c @@ -40,6 +40,14 @@ */ #define GRACE_PERIOD GNUNET_TIME_UNIT_HOURS +/** + * How much do we allow the bank and the exchange to disagree about + * timestamps? Should be sufficiently large to avoid bogus reports from deltas + * created by imperfect clock synchronization and network delay. + */ +#define TIME_TOLERANCE GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, \ + 15) + /** * Information we keep for each supported account. @@ -874,15 +882,34 @@ wire_out_cb (void *cls, } goto cleanup; } - if (roi->details.execution_date.abs_value_us != - date.abs_value_us) + { - report (report_row_minor_inconsistencies, - json_pack ("{s:s, s:I, s:s}", - "table", "wire_out", - "row", (json_int_t) rowid, - "diagnostic", "execution date missmatch")); + struct GNUNET_TIME_Relative delta; + + if (roi->details.execution_date.abs_value_us > + date.abs_value_us) + delta = GNUNET_TIME_absolute_get_difference (date, + roi->details.execution_date); + else + delta = GNUNET_TIME_absolute_get_difference (roi->details.execution_date, + date); + if (delta.rel_value_us > TIME_TOLERANCE.rel_value_us) + { + char *details; + + GNUNET_asprintf (&details, + "execution date missmatch (%s)", + GNUNET_STRINGS_relative_time_to_string (delta, + GNUNET_YES)); + report (report_row_minor_inconsistencies, + json_pack ("{s:s, s:I, s:s}", + "table", "wire_out", + "row", (json_int_t) rowid, + "diagnostic", details)); + GNUNET_free (details); + } } + cleanup: GNUNET_assert (GNUNET_OK == free_roi (NULL, |