aboutsummaryrefslogtreecommitdiff
path: root/src/auditor/taler-helper-auditor-aggregation.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/auditor/taler-helper-auditor-aggregation.c')
-rw-r--r--src/auditor/taler-helper-auditor-aggregation.c209
1 files changed, 113 insertions, 96 deletions
diff --git a/src/auditor/taler-helper-auditor-aggregation.c b/src/auditor/taler-helper-auditor-aggregation.c
index cdcbd37d1..4990ae405 100644
--- a/src/auditor/taler-helper-auditor-aggregation.c
+++ b/src/auditor/taler-helper-auditor-aggregation.c
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of TALER 2 This file is part of TALER
3 Copyright (C) 2016-2020 Taler Systems SA 3 Copyright (C) 2016-2021 Taler Systems SA
4 4
5 TALER is free software; you can redistribute it and/or modify it under the 5 TALER is free software; you can redistribute it and/or modify it under the
6 terms of the GNU Affero Public License as published by the Free Software 6 terms of the GNU Affero Public License as published by the Free Software
@@ -163,12 +163,17 @@ report_amount_arithmetic_inconsistency (
163 exchange); 163 exchange);
164 } 164 }
165 TALER_ARL_report (report_amount_arithmetic_inconsistencies, 165 TALER_ARL_report (report_amount_arithmetic_inconsistencies,
166 json_pack ("{s:s, s:I, s:o, s:o, s:I}", 166 GNUNET_JSON_PACK (
167 "operation", operation, 167 GNUNET_JSON_pack_string ("operation",
168 "rowid", (json_int_t) rowid, 168 operation),
169 "exchange", TALER_JSON_from_amount (exchange), 169 GNUNET_JSON_pack_uint64 ("rowid",
170 "auditor", TALER_JSON_from_amount (auditor), 170 rowid),
171 "profitable", (json_int_t) profitable)); 171 TALER_JSON_pack_amount ("exchange",
172 exchange),
173 TALER_JSON_pack_amount ("auditor",
174 auditor),
175 GNUNET_JSON_pack_int64 ("profitable",
176 profitable)));
172 if (0 != profitable) 177 if (0 != profitable)
173 { 178 {
174 target = (1 == profitable) 179 target = (1 == profitable)
@@ -222,13 +227,17 @@ report_coin_arithmetic_inconsistency (
222 exchange); 227 exchange);
223 } 228 }
224 TALER_ARL_report (report_coin_inconsistencies, 229 TALER_ARL_report (report_coin_inconsistencies,
225 json_pack ("{s:s, s:o, s:o, s:o, s:I}", 230 GNUNET_JSON_PACK (
226 "operation", operation, 231 GNUNET_JSON_pack_string ("operation",
227 "coin_pub", GNUNET_JSON_from_data_auto ( 232 operation),
228 coin_pub), 233 GNUNET_JSON_pack_data_auto ("coin_pub",
229 "exchange", TALER_JSON_from_amount (exchange), 234 coin_pub),
230 "auditor", TALER_JSON_from_amount (auditor), 235 TALER_JSON_pack_amount ("exchange",
231 "profitable", (json_int_t) profitable)); 236 exchange),
237 TALER_JSON_pack_amount ("auditor",
238 auditor),
239 GNUNET_JSON_pack_int64 ("profitable",
240 profitable)));
232 if (0 != profitable) 241 if (0 != profitable)
233 { 242 {
234 target = (1 == profitable) 243 target = (1 == profitable)
@@ -254,10 +263,13 @@ report_row_inconsistency (const char *table,
254 const char *diagnostic) 263 const char *diagnostic)
255{ 264{
256 TALER_ARL_report (report_row_inconsistencies, 265 TALER_ARL_report (report_row_inconsistencies,
257 json_pack ("{s:s, s:I, s:s}", 266 GNUNET_JSON_PACK (
258 "table", table, 267 GNUNET_JSON_pack_string ("table",
259 "row", (json_int_t) rowid, 268 table),
260 "diagnostic", diagnostic)); 269 GNUNET_JSON_pack_uint64 ("row",
270 rowid),
271 GNUNET_JSON_pack_string ("diagnostic",
272 diagnostic)));
261} 273}
262 274
263 275
@@ -797,12 +809,15 @@ wire_transfer_information_cb (
797 denom_pub)) 809 denom_pub))
798 { 810 {
799 TALER_ARL_report (report_bad_sig_losses, 811 TALER_ARL_report (report_bad_sig_losses,
800 json_pack ("{s:s, s:I, s:o, s:o}", 812 GNUNET_JSON_PACK (
801 "operation", "wire", 813 GNUNET_JSON_pack_string ("operation",
802 "row", (json_int_t) rowid, 814 "wire"),
803 "loss", TALER_JSON_from_amount (coin_value), 815 GNUNET_JSON_pack_uint64 ("row",
804 "coin_pub", GNUNET_JSON_from_data_auto ( 816 rowid),
805 &coin.coin_pub))); 817 TALER_JSON_pack_amount ("loss",
818 coin_value),
819 GNUNET_JSON_pack_data_auto ("coin_pub",
820 &coin.coin_pub)));
806 TALER_ARL_amount_add (&total_bad_sig_loss, 821 TALER_ARL_amount_add (&total_bad_sig_loss,
807 &total_bad_sig_loss, 822 &total_bad_sig_loss,
808 coin_value); 823 coin_value);
@@ -985,23 +1000,25 @@ get_wire_fee (struct AggregationContext *ac,
985 (wfi->prev->end_date.abs_value_us > wfi->start_date.abs_value_us) ) 1000 (wfi->prev->end_date.abs_value_us > wfi->start_date.abs_value_us) )
986 { 1001 {
987 TALER_ARL_report (report_fee_time_inconsistencies, 1002 TALER_ARL_report (report_fee_time_inconsistencies,
988 json_pack ("{s:s, s:s, s:o}", 1003 GNUNET_JSON_PACK (
989 "type", method, 1004 GNUNET_JSON_pack_string ("type",
990 "diagnostic", 1005 method),
991 "start date before previous end date", 1006 GNUNET_JSON_pack_string ("diagnostic",
992 "time", TALER_ARL_json_from_time_abs ( 1007 "start date before previous end date"),
993 wfi->start_date))); 1008 TALER_JSON_pack_time_abs_human ("time",
1009 wfi->start_date)));
994 } 1010 }
995 if ( (NULL != wfi->next) && 1011 if ( (NULL != wfi->next) &&
996 (wfi->next->start_date.abs_value_us >= wfi->end_date.abs_value_us) ) 1012 (wfi->next->start_date.abs_value_us >= wfi->end_date.abs_value_us) )
997 { 1013 {
998 TALER_ARL_report (report_fee_time_inconsistencies, 1014 TALER_ARL_report (report_fee_time_inconsistencies,
999 json_pack ("{s:s, s:s, s:o}", 1015 GNUNET_JSON_PACK (
1000 "type", method, 1016 GNUNET_JSON_pack_string ("type",
1001 "diagnostic", 1017 method),
1002 "end date date after next start date", 1018 GNUNET_JSON_pack_string ("diagnostic",
1003 "time", TALER_ARL_json_from_time_abs ( 1019 "end date date after next start date"),
1004 wfi->end_date))); 1020 TALER_JSON_pack_time_abs_human ("time",
1021 wfi->end_date)));
1005 } 1022 }
1006 return &wfi->wire_fee; 1023 return &wfi->wire_fee;
1007} 1024}
@@ -1164,13 +1181,15 @@ check_wire_out_cb (void *cls,
1164 } 1181 }
1165 1182
1166 TALER_ARL_report (report_wire_out_inconsistencies, 1183 TALER_ARL_report (report_wire_out_inconsistencies,
1167 json_pack ("{s:O, s:I, s:o, s:o}", 1184 GNUNET_JSON_PACK (
1168 "destination_account", wire, 1185 GNUNET_JSON_pack_object_incref ("destination_account",
1169 "rowid", (json_int_t) rowid, 1186 (json_t *) wire),
1170 "expected", 1187 GNUNET_JSON_pack_uint64 ("rowid",
1171 TALER_JSON_from_amount (&final_amount), 1188 rowid),
1172 "claimed", 1189 TALER_JSON_pack_amount ("expected",
1173 TALER_JSON_from_amount (amount))); 1190 &final_amount),
1191 TALER_JSON_pack_amount ("claimed",
1192 amount)));
1174 if (TALER_ARL_do_abort ()) 1193 if (TALER_ARL_do_abort ())
1175 return GNUNET_SYSERR; 1194 return GNUNET_SYSERR;
1176 return GNUNET_OK; 1195 return GNUNET_OK;
@@ -1323,8 +1342,6 @@ run (void *cls,
1323 const char *cfgfile, 1342 const char *cfgfile,
1324 const struct GNUNET_CONFIGURATION_Handle *c) 1343 const struct GNUNET_CONFIGURATION_Handle *c)
1325{ 1344{
1326 json_t *report;
1327
1328 (void) cls; 1345 (void) cls;
1329 (void) args; 1346 (void) args;
1330 (void) cfgfile; 1347 (void) cfgfile;
@@ -1333,7 +1350,7 @@ run (void *cls,
1333 if (GNUNET_OK != 1350 if (GNUNET_OK !=
1334 TALER_ARL_init (c)) 1351 TALER_ARL_init (c))
1335 { 1352 {
1336 global_ret = 1; 1353 global_ret = EXIT_FAILURE;
1337 return; 1354 return;
1338 } 1355 }
1339 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1356 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -1387,71 +1404,71 @@ run (void *cls,
1387 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 1404 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1388 "Audit failed\n"); 1405 "Audit failed\n");
1389 TALER_ARL_done (NULL); 1406 TALER_ARL_done (NULL);
1390 global_ret = 1; 1407 global_ret = EXIT_FAILURE;
1391 return; 1408 return;
1392 } 1409 }
1393 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1410 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1394 "Audit complete\n"); 1411 "Audit complete\n");
1395 report = json_pack ("{s:o, s:o, s:o, s:o, s:o," 1412 TALER_ARL_done (GNUNET_JSON_PACK (
1396 " s:o, s:o, s:o, s:o, s:o," 1413 /* blocks #1 */
1397 " s:o, s:o, s:o, s:I, s:I," 1414 GNUNET_JSON_pack_array_steal (
1398 " s:o, s:o, s:o }",
1399 /* blocks #1 */
1400 "wire_out_inconsistencies", 1415 "wire_out_inconsistencies",
1401 report_wire_out_inconsistencies, 1416 report_wire_out_inconsistencies),
1402 /* Tested in test-auditor.sh #23 */ 1417 /* Tested in test-auditor.sh #23 */
1418 TALER_JSON_pack_amount (
1403 "total_wire_out_delta_plus", 1419 "total_wire_out_delta_plus",
1404 TALER_JSON_from_amount ( 1420 &total_wire_out_delta_plus),
1405 &total_wire_out_delta_plus), 1421 /* Tested in test-auditor.sh #23 */
1406 /* Tested in test-auditor.sh #23 */ 1422 TALER_JSON_pack_amount (
1407 "total_wire_out_delta_minus", 1423 "total_wire_out_delta_minus",
1408 TALER_JSON_from_amount ( 1424 &total_wire_out_delta_minus),
1409 &total_wire_out_delta_minus), 1425 /* Tested in test-auditor.sh #28/32 */
1410 /* Tested in test-auditor.sh #28/32 */ 1426 GNUNET_JSON_pack_array_steal ("bad_sig_losses",
1411 "bad_sig_losses", 1427 report_bad_sig_losses),
1412 report_bad_sig_losses, 1428 /* Tested in test-auditor.sh #28/32 */
1413 /* Tested in test-auditor.sh #28/32 */ 1429 TALER_JSON_pack_amount ("total_bad_sig_loss",
1414 "total_bad_sig_loss", 1430 &total_bad_sig_loss),
1415 TALER_JSON_from_amount (&total_bad_sig_loss), 1431 /* block #2 */
1416 /* block #2 */ 1432 /* Tested in test-auditor.sh #15 */
1417 /* Tested in test-auditor.sh #15 */ 1433 GNUNET_JSON_pack_array_steal (
1418 "row_inconsistencies", 1434 "row_inconsistencies",
1419 report_row_inconsistencies, 1435 report_row_inconsistencies),
1436 GNUNET_JSON_pack_array_steal (
1420 "coin_inconsistencies", 1437 "coin_inconsistencies",
1421 report_coin_inconsistencies, 1438 report_coin_inconsistencies),
1422 "total_coin_delta_plus", 1439 TALER_JSON_pack_amount ("total_coin_delta_plus",
1423 TALER_JSON_from_amount (&total_coin_delta_plus), 1440 &total_coin_delta_plus),
1424 "total_coin_delta_minus", 1441 TALER_JSON_pack_amount ("total_coin_delta_minus",
1425 TALER_JSON_from_amount ( 1442 &total_coin_delta_minus),
1426 &total_coin_delta_minus), 1443 GNUNET_JSON_pack_array_steal (
1427 "amount_arithmetic_inconsistencies", 1444 "amount_arithmetic_inconsistencies",
1428 report_amount_arithmetic_inconsistencies, 1445 report_amount_arithmetic_inconsistencies),
1429 /* block #3 */ 1446 /* block #3 */
1447 TALER_JSON_pack_amount (
1430 "total_arithmetic_delta_plus", 1448 "total_arithmetic_delta_plus",
1431 TALER_JSON_from_amount ( 1449 &total_arithmetic_delta_plus),
1432 &total_arithmetic_delta_plus), 1450 TALER_JSON_pack_amount (
1433 "total_arithmetic_delta_minus", 1451 "total_arithmetic_delta_minus",
1434 TALER_JSON_from_amount ( 1452 &total_arithmetic_delta_minus),
1435 &total_arithmetic_delta_minus), 1453 TALER_JSON_pack_amount (
1436 "total_aggregation_fee_income", 1454 "total_aggregation_fee_income",
1437 TALER_JSON_from_amount ( 1455 &total_aggregation_fee_income),
1438 &total_aggregation_fee_income), 1456 GNUNET_JSON_pack_uint64 (
1439 "start_ppa_wire_out_serial_id", 1457 "start_ppa_wire_out_serial_id",
1440 (json_int_t) ppa_start.last_wire_out_serial_id, 1458 ppa_start.last_wire_out_serial_id),
1459 GNUNET_JSON_pack_uint64 (
1441 "end_ppa_wire_out_serial_id", 1460 "end_ppa_wire_out_serial_id",
1442 (json_int_t) ppa.last_wire_out_serial_id, 1461 ppa.last_wire_out_serial_id),
1443 /* block #4 */ 1462 /* block #4 */
1463 TALER_JSON_pack_time_abs_human (
1444 "auditor_start_time", 1464 "auditor_start_time",
1445 TALER_ARL_json_from_time_abs ( 1465 start_time),
1446 start_time), 1466 TALER_JSON_pack_time_abs_human (
1447 "auditor_end_time", 1467 "auditor_end_time",
1448 TALER_ARL_json_from_time_abs ( 1468 GNUNET_TIME_absolute_get ()),
1449 GNUNET_TIME_absolute_get ()), 1469 GNUNET_JSON_pack_array_steal (
1450 "wire_fee_time_inconsistencies", 1470 "wire_fee_time_inconsistencies",
1451 report_fee_time_inconsistencies 1471 report_fee_time_inconsistencies)));
1452 );
1453 GNUNET_break (NULL != report);
1454 TALER_ARL_done (report);
1455} 1472}
1456 1473
1457 1474
@@ -1489,7 +1506,7 @@ main (int argc,
1489 if (GNUNET_OK != 1506 if (GNUNET_OK !=
1490 GNUNET_STRINGS_get_utf8_args (argc, argv, 1507 GNUNET_STRINGS_get_utf8_args (argc, argv,
1491 &argc, &argv)) 1508 &argc, &argv))
1492 return 4; 1509 return EXIT_INVALIDARGUMENT;
1493 ret = GNUNET_PROGRAM_run ( 1510 ret = GNUNET_PROGRAM_run (
1494 argc, 1511 argc,
1495 argv, 1512 argv,
@@ -1500,9 +1517,9 @@ main (int argc,
1500 NULL); 1517 NULL);
1501 GNUNET_free_nz ((void *) argv); 1518 GNUNET_free_nz ((void *) argv);
1502 if (GNUNET_SYSERR == ret) 1519 if (GNUNET_SYSERR == ret)
1503 return 3; 1520 return EXIT_INVALIDARGUMENT;
1504 if (GNUNET_NO == ret) 1521 if (GNUNET_NO == ret)
1505 return 0; 1522 return EXIT_SUCCESS;
1506 return global_ret; 1523 return global_ret;
1507} 1524}
1508 1525