aboutsummaryrefslogtreecommitdiff
path: root/src/auditor/taler-helper-auditor-reserves.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/auditor/taler-helper-auditor-reserves.c')
-rw-r--r--src/auditor/taler-helper-auditor-reserves.c98
1 files changed, 87 insertions, 11 deletions
diff --git a/src/auditor/taler-helper-auditor-reserves.c b/src/auditor/taler-helper-auditor-reserves.c
index fdbdea2a1..b02bb3a00 100644
--- a/src/auditor/taler-helper-auditor-reserves.c
+++ b/src/auditor/taler-helper-auditor-reserves.c
@@ -1455,11 +1455,35 @@ verify_reserve_balance (void *cls,
TALER_ARL_amount_add (&mbalance,
&rs->total_in,
&rs->prev_balance.reserve_balance);
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ " nbalance: %s\n",
+ TALER_amount_to_string (&nbalance));
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ " mbalance: %s\n",
+ TALER_amount_to_string (&nbalance));
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ " total out: %s\n",
+ TALER_amount_to_string (&rs->total_out));
+
if (TALER_ARL_SR_INVALID_NEGATIVE ==
TALER_ARL_amount_subtract_neg (&nbalance,
&mbalance,
&rs->total_out))
{
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ " Going in here because it can't be correct: %s\n",
+ TALER_amount_to_string (&nbalance));
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ " nbalance: %s\n",
+ TALER_amount_to_string (&nbalance));
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ " mbalance: %s\n",
+ TALER_amount_to_string (&nbalance));
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ " total out: %s\n",
+ TALER_amount_to_string (&rs->total_out));
+
+
struct TALER_Amount loss;
TALER_ARL_amount_subtract (&loss,
@@ -1502,8 +1526,17 @@ verify_reserve_balance (void *cls,
rs->curr_balance.reserve_balance = nbalance;
}
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "1curr_balance.reserve_balance: %s\n",
+ TALER_amount_to_string (&rs->curr_balance.reserve_balance));
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "1nbalance: %s\n",
+ TALER_amount_to_string (&nbalance));
+
if (internal_checks)
{
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ " Going in here because internal checks is active\n");
/* Now check OUR balance calculation vs. the one the exchange has
in its database. This can only be done when we are doing an
internal audit, as otherwise the balance of the 'reserves' table
@@ -1524,7 +1557,9 @@ verify_reserve_balance (void *cls,
rbiig.reserve_pub = rs->reserve_pub.eddsa_pub;
rbiig.inconsistency_amount = nbalance;
rbiig.inconsistency_gain = true;
-
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "1inconsistency_amount: %s\n",
+ TALER_amount_to_string (&rbiig.inconsistency_amount));
qs = TALER_ARL_adb->insert_reserve_balance_insufficient_inconsistency (
TALER_ARL_adb->cls,
&rbiig);
@@ -1534,6 +1569,10 @@ verify_reserve_balance (void *cls,
GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs);
}
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "2nbalance: %s\n",
+ TALER_amount_to_string (&nbalance));
+
TALER_ARL_report (report_reserve_balance_insufficient_inconsistencies,
GNUNET_JSON_PACK (
GNUNET_JSON_pack_data_auto ("reserve_pub",
@@ -1553,6 +1592,10 @@ verify_reserve_balance (void *cls,
if (0 != TALER_amount_cmp (&rs->curr_balance.reserve_balance,
&reserve.balance))
{
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "3nbalance: %s\n",
+ TALER_amount_to_string (&nbalance));
+
struct TALER_Amount delta;
if (0 < TALER_amount_cmp (&rs->curr_balance.reserve_balance,
@@ -1601,6 +1644,9 @@ verify_reserve_balance (void *cls,
GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs);
}
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "4nbalance: %s\n",
+ TALER_amount_to_string (&nbalance));
TALER_ARL_report (report_reserve_balance_summary_wrong_inconsistencies,
GNUNET_JSON_PACK (
GNUNET_JSON_pack_data_auto ("reserve_pub",
@@ -1614,6 +1660,13 @@ verify_reserve_balance (void *cls,
}
} /* end of 'if (internal_checks)' */
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Amount of total balance reserve not closed: %s\n",
+ TALER_amount_to_string (&total_balance_reserve_not_closed));
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "nbalance: %s\n",
+ TALER_amount_to_string (&nbalance));
+
/* Check that reserve is being closed if it is past its expiration date
(and the closing fee would not exceed the remaining balance) */
if (GNUNET_TIME_relative_cmp (CLOSING_GRACE_PERIOD,
@@ -1634,6 +1687,13 @@ verify_reserve_balance (void *cls,
if (1 == TALER_amount_cmp (&nbalance,
&cfee))
{
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "2 Amount of total balance reserve not closed: %s\n",
+ TALER_amount_to_string (&total_balance_reserve_not_closed));
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "1 nbalance: %s\n",
+ TALER_amount_to_string (&nbalance));
+
/* remaining balance (according to us) exceeds closing fee */
TALER_ARL_amount_add (&total_balance_reserve_not_closed,
&total_balance_reserve_not_closed,
@@ -1663,25 +1723,36 @@ verify_reserve_balance (void *cls,
}
else
{
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "2 Amount of total balance reserve not closed: %s\n",
+ TALER_amount_to_string (&total_balance_reserve_not_closed));
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "2 nbalance: %s\n",
+ TALER_amount_to_string (&nbalance));
+
/* We failed to determine the closing fee, complain! */
- TALER_ARL_amount_add (&total_balance_reserve_not_closed,
+ // TODO: fix correctly and not just comment out
+ // nbalance get's set to invalid and there is never a check happening when working further with nbalance,
+ // why so and why adding those balances here? or what's the usecase of setting nbalance to zero?
+ /*TALER_ARL_amount_add (&total_balance_reserve_not_closed,
&total_balance_reserve_not_closed,
- &nbalance);
+ &nbalance);*/
rncid.reserve_pub = rs->reserve_pub;
- rncid.balance = nbalance;
+ rncid.balance = (nbalance.value) ? total_balance_reserve_not_closed :
+ nbalance;
rncid.expiration_time = rs->a_expiration_date.abs_time;
rncid.diagnostic = "could not determine closing fee";
-
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO, " 11 here\n");
qs = TALER_ARL_adb->insert_reserve_not_closed_inconsistency (
TALER_ARL_adb->cls,
&rncid);
-
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO, " 12 here\n");
if (qs < 0)
{
GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs);
}
- TALER_ARL_report (
+ /*TALER_ARL_report (
report_reserve_not_closed_inconsistencies,
GNUNET_JSON_PACK (
GNUNET_JSON_pack_data_auto ("reserve_pub",
@@ -1691,10 +1762,10 @@ verify_reserve_balance (void *cls,
TALER_JSON_pack_time_abs_human ("expiration_time",
rs->a_expiration_date.abs_time),
GNUNET_JSON_pack_string ("diagnostic",
- "could not determine closing fee")));
+ "could not determine closing fee")));*/
}
}
-
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO, " 1 here\n");
/* We already computed the 'new' balance in 'curr_balance'
to include the previous balance, so this one is just
an assignment, not adding up! */
@@ -1719,7 +1790,7 @@ verify_reserve_balance (void *cls,
TALER_ARL_amount_add (&rs->prev_balance.history_fee_balance,
&rs->prev_balance.history_fee_balance,
&rs->curr_balance.history_fee_balance);
-
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO, " 2 here\n");
/* Update global balance: add incoming first, then try
to subtract outgoing... */
TALER_ARL_amount_add (&TALER_ARL_USE_AB (reserves_reserve_total_balance),
@@ -1755,7 +1826,7 @@ verify_reserve_balance (void *cls,
TALER_ARL_USE_AB (reserves_reserve_total_balance) = r;
}
}
-
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO, " 3 here\n");
if (TALER_amount_is_zero (&rs->prev_balance.reserve_balance))
{
/* balance is zero, drop reserve details (and then do not update/insert) */
@@ -1805,6 +1876,7 @@ verify_reserve_balance (void *cls,
rc->qs = qs;
}
}
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO, " 4 here\n");
/* now we can discard the cached entry */
GNUNET_assert (GNUNET_YES ==
GNUNET_CONTAINER_multihashmap_remove (rc->reserves,
@@ -1812,6 +1884,7 @@ verify_reserve_balance (void *cls,
rs));
GNUNET_free (rs->sender_account);
GNUNET_free (rs);
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO, " 5 here\n");
return ret;
}
@@ -1987,6 +2060,9 @@ analyze_reserves (void *cls)
GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs);
return qs;
}
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ " Size of rc.reserves %u \n",
+ GNUNET_CONTAINER_multihashmap_size (rc.reserves));
GNUNET_CONTAINER_multihashmap_iterate (rc.reserves,
&verify_reserve_balance,
&rc);