add ppc progress points for payback ops

This commit is contained in:
Christian Grothoff 2019-07-24 14:13:25 +02:00
parent bad3e3dc4a
commit 03af37ef23
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC
4 changed files with 156 additions and 51 deletions

View File

@ -3906,6 +3906,65 @@ refund_cb (void *cls,
} }
/**
* Function called about paybacks the exchange has to perform.
*
* @param cls closure
* @param rowid row identifier used to uniquely identify the payback operation
* @param timestamp when did we receive the payback request
* @param amount how much should be added back to the reserve
* @param reserve_pub public key of the reserve
* @param coin public information about the coin
* @param coin_sig signature with @e coin_pub of type #TALER_SIGNATURE_WALLET_COIN_PAYBACK
* @param coin_blind blinding factor used to blind the coin
* @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop
*/
static int
payback_cb (void *cls,
uint64_t rowid,
struct GNUNET_TIME_Absolute timestamp,
const struct TALER_Amount *amount,
const struct TALER_ReservePublicKeyP *reserve_pub,
const struct TALER_CoinPublicInfo *coin,
const struct TALER_DenominationPublicKey *denom_pub,
const struct TALER_CoinSpendSignatureP *coin_sig,
const struct TALER_DenominationBlindingKeyP *coin_blind)
{
GNUNET_assert (0); // #5777: NOT implemented! (updated losses from payback/denomination)
return GNUNET_SYSERR;
}
/**
* Function called about paybacks on refreshed coins the exchange has to
* perform.
*
* @param cls closure
* @param rowid row identifier used to uniquely identify the payback operation
* @param timestamp when did we receive the payback request
* @param amount how much should be added back to the reserve
* @param old_coin_pub original coin that was refreshed to create @a coin
* @param coin public information about the coin
* @param coin_sig signature with @e coin_pub of type #TALER_SIGNATURE_WALLET_COIN_PAYBACK
* @param coin_blind blinding factor used to blind the coin
* @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop
*/
static int
payback_refresh_cb (void *cls,
uint64_t rowid,
struct GNUNET_TIME_Absolute timestamp,
const struct TALER_Amount *amount,
const struct TALER_CoinSpendPublicKeyP *old_coin_pub,
const struct TALER_CoinPublicInfo *coin,
const struct TALER_DenominationPublicKey *denom_pub,
const struct TALER_CoinSpendSignatureP *coin_sig,
const struct TALER_DenominationBlindingKeyP *coin_blind)
{
GNUNET_assert (0); // #5777: NOT implemented! (updated denom gains from payback)
return GNUNET_SYSERR;
}
/** /**
* Analyze the exchange's processing of coins. * Analyze the exchange's processing of coins.
* *
@ -3939,11 +3998,12 @@ analyze_coins (void *cls)
else else
{ {
GNUNET_log (GNUNET_ERROR_TYPE_INFO, GNUNET_log (GNUNET_ERROR_TYPE_INFO,
_("Resuming coin audit at %llu/%llu/%llu/%llu\n"), _("Resuming coin audit at %llu/%llu/%llu/%llu/%llu\n"),
(unsigned long long) ppc.last_deposit_serial_id, (unsigned long long) ppc.last_deposit_serial_id,
(unsigned long long) ppc.last_melt_serial_id, (unsigned long long) ppc.last_melt_serial_id,
(unsigned long long) ppc.last_refund_serial_id, (unsigned long long) ppc.last_refund_serial_id,
(unsigned long long) ppc.last_withdraw_serial_id); (unsigned long long) ppc.last_withdraw_serial_id,
(unsigned long long) ppc.last_payback_refresh_serial_id);
} }
/* setup 'cc' */ /* setup 'cc' */
@ -4012,6 +4072,28 @@ analyze_coins (void *cls)
return qs; return qs;
} }
/* process paybacks */
if (0 >
(qs = edb->select_payback_above_serial_id (edb->cls,
esession,
ppc.last_payback_serial_id,
&payback_cb,
&cc)))
{
GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs);
return qs;
}
if (0 >
(qs = edb->select_payback_refresh_above_serial_id (edb->cls,
esession,
ppc.last_payback_refresh_serial_id,
&payback_refresh_cb,
&cc)))
{
GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs);
return qs;
}
/* sync 'cc' back to disk */ /* sync 'cc' back to disk */
cc.qs = GNUNET_DB_STATUS_SUCCESS_ONE_RESULT; cc.qs = GNUNET_DB_STATUS_SUCCESS_ONE_RESULT;
GNUNET_CONTAINER_multihashmap_iterate (cc.denom_summaries, GNUNET_CONTAINER_multihashmap_iterate (cc.denom_summaries,

View File

@ -262,6 +262,8 @@ postgres_create_tables (void *cls)
",last_deposit_serial_id INT8 NOT NULL DEFAULT 0" ",last_deposit_serial_id INT8 NOT NULL DEFAULT 0"
",last_melt_serial_id INT8 NOT NULL DEFAULT 0" ",last_melt_serial_id INT8 NOT NULL DEFAULT 0"
",last_refund_serial_id INT8 NOT NULL DEFAULT 0" ",last_refund_serial_id INT8 NOT NULL DEFAULT 0"
",last_payback_serial_id INT8 NOT NULL DEFAULT 0"
",last_payback_refresh_serial_id INT8 NOT NULL DEFAULT 0"
")"), ")"),
GNUNET_PQ_make_execute ("CREATE TABLE IF NOT EXISTS wire_auditor_progress" GNUNET_PQ_make_execute ("CREATE TABLE IF NOT EXISTS wire_auditor_progress"
"(master_pub BYTEA CONSTRAINT master_pub_ref REFERENCES auditor_exchanges(master_pub) ON DELETE CASCADE" "(master_pub BYTEA CONSTRAINT master_pub_ref REFERENCES auditor_exchanges(master_pub) ON DELETE CASCADE"
@ -674,8 +676,10 @@ postgres_prepare (PGconn *db_conn)
",last_deposit_serial_id=$2" ",last_deposit_serial_id=$2"
",last_melt_serial_id=$3" ",last_melt_serial_id=$3"
",last_refund_serial_id=$4" ",last_refund_serial_id=$4"
" WHERE master_pub=$5", ",last_payback_serial_id=$5"
4), ",last_payback_refresh_serial_id=$6"
" WHERE master_pub=$7",
7),
/* Used in #postgres_get_auditor_progress_coin() */ /* Used in #postgres_get_auditor_progress_coin() */
GNUNET_PQ_make_prepare ("auditor_progress_select_coin", GNUNET_PQ_make_prepare ("auditor_progress_select_coin",
"SELECT" "SELECT"
@ -683,6 +687,8 @@ postgres_prepare (PGconn *db_conn)
",last_deposit_serial_id" ",last_deposit_serial_id"
",last_melt_serial_id" ",last_melt_serial_id"
",last_refund_serial_id" ",last_refund_serial_id"
",last_payback_serial_id"
",last_payback_refresh_serial_id"
" FROM auditor_progress_coin" " FROM auditor_progress_coin"
" WHERE master_pub=$1;", " WHERE master_pub=$1;",
1), 1),
@ -694,8 +700,10 @@ postgres_prepare (PGconn *db_conn)
",last_deposit_serial_id" ",last_deposit_serial_id"
",last_melt_serial_id" ",last_melt_serial_id"
",last_refund_serial_id" ",last_refund_serial_id"
") VALUES ($1,$2,$3,$4,$5);", ",last_payback_serial_id"
5), ",last_payback_refresh_serial_id"
") VALUES ($1,$2,$3,$4,$5,$6,$7);",
7),
/* Used in #postgres_insert_wire_auditor_progress() */ /* Used in #postgres_insert_wire_auditor_progress() */
GNUNET_PQ_make_prepare ("wire_auditor_progress_insert", GNUNET_PQ_make_prepare ("wire_auditor_progress_insert",
"INSERT INTO wire_auditor_progress " "INSERT INTO wire_auditor_progress "
@ -2053,6 +2061,8 @@ postgres_insert_auditor_progress_coin (void *cls,
GNUNET_PQ_query_param_uint64 (&ppc->last_deposit_serial_id), GNUNET_PQ_query_param_uint64 (&ppc->last_deposit_serial_id),
GNUNET_PQ_query_param_uint64 (&ppc->last_melt_serial_id), GNUNET_PQ_query_param_uint64 (&ppc->last_melt_serial_id),
GNUNET_PQ_query_param_uint64 (&ppc->last_refund_serial_id), GNUNET_PQ_query_param_uint64 (&ppc->last_refund_serial_id),
GNUNET_PQ_query_param_uint64 (&ppc->last_payback_serial_id),
GNUNET_PQ_query_param_uint64 (&ppc->last_payback_refresh_serial_id),
GNUNET_PQ_query_param_end GNUNET_PQ_query_param_end
}; };
@ -2083,6 +2093,8 @@ postgres_update_auditor_progress_coin (void *cls,
GNUNET_PQ_query_param_uint64 (&ppc->last_deposit_serial_id), GNUNET_PQ_query_param_uint64 (&ppc->last_deposit_serial_id),
GNUNET_PQ_query_param_uint64 (&ppc->last_melt_serial_id), GNUNET_PQ_query_param_uint64 (&ppc->last_melt_serial_id),
GNUNET_PQ_query_param_uint64 (&ppc->last_refund_serial_id), GNUNET_PQ_query_param_uint64 (&ppc->last_refund_serial_id),
GNUNET_PQ_query_param_uint64 (&ppc->last_payback_serial_id),
GNUNET_PQ_query_param_uint64 (&ppc->last_payback_refresh_serial_id),
GNUNET_PQ_query_param_auto_from_type (master_pub), GNUNET_PQ_query_param_auto_from_type (master_pub),
GNUNET_PQ_query_param_end GNUNET_PQ_query_param_end
}; };
@ -2121,6 +2133,10 @@ postgres_get_auditor_progress_coin (void *cls,
&ppc->last_melt_serial_id), &ppc->last_melt_serial_id),
GNUNET_PQ_result_spec_uint64 ("last_refund_serial_id", GNUNET_PQ_result_spec_uint64 ("last_refund_serial_id",
&ppc->last_refund_serial_id), &ppc->last_refund_serial_id),
GNUNET_PQ_result_spec_uint64 ("last_payback_serial_id",
&ppc->last_payback_serial_id),
GNUNET_PQ_result_spec_uint64 ("last_payback_refresh_serial_id",
&ppc->last_payback_refresh_serial_id),
GNUNET_PQ_result_spec_end GNUNET_PQ_result_spec_end
}; };

View File

@ -230,6 +230,16 @@ struct TALER_AUDITORDB_ProgressPointCoin
*/ */
uint64_t last_refund_serial_id; uint64_t last_refund_serial_id;
/**
* Serial ID of the last payback operation the auditor processed.
*/
uint64_t last_payback_serial_id;
/**
* Serial ID of the last payback-of-refresh operation the auditor processed.
*/
uint64_t last_payback_refresh_serial_id;
}; };

View File

@ -1138,7 +1138,6 @@ typedef int
const struct TALER_DenominationBlindingKeyP *coin_blind); const struct TALER_DenominationBlindingKeyP *coin_blind);
/** /**
* Function called about paybacks on refreshed coins the exchange has to * Function called about paybacks on refreshed coins the exchange has to
* perform. * perform.
@ -1165,8 +1164,6 @@ typedef int
const struct TALER_DenominationBlindingKeyP *coin_blind); const struct TALER_DenominationBlindingKeyP *coin_blind);
/** /**
* Function called about reserve closing operations * Function called about reserve closing operations
* the aggregator triggered. * the aggregator triggered.