implement batch operation in handlers
This commit is contained in:
parent
8bfc6583e7
commit
41e3c1ecbf
@ -413,24 +413,24 @@ static MHD_RESULT
|
|||||||
prepare_transaction (const struct TEH_RequestContext *rc,
|
prepare_transaction (const struct TEH_RequestContext *rc,
|
||||||
struct BatchWithdrawContext *wc)
|
struct BatchWithdrawContext *wc)
|
||||||
{
|
{
|
||||||
/* Note: We could check the reserve balance here,
|
struct TEH_CoinSignData csds[wc->planchets_length];
|
||||||
just to be reasonably sure that the reserve has
|
struct TALER_BlindedDenominationSignature bss[wc->planchets_length];
|
||||||
a sufficient balance before doing the "expensive"
|
|
||||||
signatures... */
|
|
||||||
/* Sign before transaction! */
|
|
||||||
for (unsigned int i = 0; i<wc->planchets_length; i++)
|
for (unsigned int i = 0; i<wc->planchets_length; i++)
|
||||||
{
|
{
|
||||||
struct PlanchetContext *pc = &wc->planchets[i];
|
struct PlanchetContext *pc = &wc->planchets[i];
|
||||||
enum TALER_ErrorCode ec;
|
|
||||||
struct TEH_CoinSignData csds = {
|
|
||||||
.h_denom_pub = &pc->collectable.denom_pub_hash,
|
|
||||||
.bp = &pc->blinded_planchet
|
|
||||||
};
|
|
||||||
|
|
||||||
ec = TEH_keys_denomination_sign (
|
csds[i].h_denom_pub = &pc->collectable.denom_pub_hash;
|
||||||
&csds,
|
csds[i].bp = &pc->blinded_planchet;
|
||||||
|
}
|
||||||
|
{
|
||||||
|
enum TALER_ErrorCode ec;
|
||||||
|
|
||||||
|
ec = TEH_keys_denomination_batch_sign (
|
||||||
|
csds,
|
||||||
|
wc->planchets_length,
|
||||||
false,
|
false,
|
||||||
&pc->collectable.sig);
|
bss);
|
||||||
if (TALER_EC_NONE != ec)
|
if (TALER_EC_NONE != ec)
|
||||||
{
|
{
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
@ -439,6 +439,12 @@ prepare_transaction (const struct TEH_RequestContext *rc,
|
|||||||
NULL);
|
NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for (unsigned int i = 0; i<wc->planchets_length; i++)
|
||||||
|
{
|
||||||
|
struct PlanchetContext *pc = &wc->planchets[i];
|
||||||
|
|
||||||
|
pc->collectable.sig = bss[i];
|
||||||
|
}
|
||||||
|
|
||||||
/* run transaction */
|
/* run transaction */
|
||||||
{
|
{
|
||||||
|
@ -75,10 +75,11 @@ TEH_handler_csr_melt (struct TEH_RequestContext *rc,
|
|||||||
|
|
||||||
{
|
{
|
||||||
struct TALER_ExchangeWithdrawValues ewvs[csr_requests_num];
|
struct TALER_ExchangeWithdrawValues ewvs[csr_requests_num];
|
||||||
|
|
||||||
{
|
{
|
||||||
struct TALER_CsNonce nonces[csr_requests_num];
|
struct TALER_CsNonce nonces[csr_requests_num];
|
||||||
struct TALER_DenominationHashP denom_pub_hashes[csr_requests_num];
|
struct TALER_DenominationHashP denom_pub_hashes[csr_requests_num];
|
||||||
|
struct TEH_CsDeriveData cdds[csr_requests_num];
|
||||||
|
struct TALER_DenominationCSPublicRPairP r_pubs[csr_requests_num];
|
||||||
|
|
||||||
for (unsigned int i = 0; i < csr_requests_num; i++)
|
for (unsigned int i = 0; i < csr_requests_num; i++)
|
||||||
{
|
{
|
||||||
@ -114,8 +115,6 @@ TEH_handler_csr_melt (struct TEH_RequestContext *rc,
|
|||||||
const struct TALER_CsNonce *nonce = &nonces[i];
|
const struct TALER_CsNonce *nonce = &nonces[i];
|
||||||
const struct TALER_DenominationHashP *denom_pub_hash =
|
const struct TALER_DenominationHashP *denom_pub_hash =
|
||||||
&denom_pub_hashes[i];
|
&denom_pub_hashes[i];
|
||||||
struct TALER_DenominationCSPublicRPairP *r_pub
|
|
||||||
= &ewvs[i].details.cs_values;
|
|
||||||
|
|
||||||
ewvs[i].cipher = TALER_DENOMINATION_CS;
|
ewvs[i].cipher = TALER_DENOMINATION_CS;
|
||||||
/* check denomination referenced by denom_pub_hash */
|
/* check denomination referenced by denom_pub_hash */
|
||||||
@ -176,28 +175,23 @@ TEH_handler_csr_melt (struct TEH_RequestContext *rc,
|
|||||||
denom_pub_hash);
|
denom_pub_hash);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
cdds[i].h_denom_pub = denom_pub_hash;
|
||||||
/* derive r_pub */
|
cdds[i].nonce = nonce;
|
||||||
// FIXME-#7272: bundle all requests into one derivation request (TEH_keys_..., crypto helper, security module)
|
} /* for (i) */
|
||||||
{
|
ec = TEH_keys_denomination_cs_batch_r_pub (cdds,
|
||||||
const struct TEH_CsDeriveData cdd = {
|
csr_requests_num,
|
||||||
.h_denom_pub = denom_pub_hash,
|
true,
|
||||||
.nonce = nonce
|
r_pubs);
|
||||||
};
|
if (TALER_EC_NONE != ec)
|
||||||
|
{
|
||||||
ec = TEH_keys_denomination_cs_r_pub (&cdd,
|
GNUNET_break (0);
|
||||||
true,
|
return TALER_MHD_reply_with_ec (rc->connection,
|
||||||
r_pub);
|
ec,
|
||||||
}
|
NULL);
|
||||||
if (TALER_EC_NONE != ec)
|
|
||||||
{
|
|
||||||
GNUNET_break (0);
|
|
||||||
return TALER_MHD_reply_with_ec (rc->connection,
|
|
||||||
ec,
|
|
||||||
NULL);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
for (unsigned int i = 0; i < csr_requests_num; i++)
|
||||||
|
ewvs[i].details.cs_values = r_pubs[i];
|
||||||
|
} /* end scope */
|
||||||
|
|
||||||
/* send response */
|
/* send response */
|
||||||
{
|
{
|
||||||
|
@ -750,20 +750,21 @@ clean_age:
|
|||||||
(unsigned int) rctx->num_fresh_coins);
|
(unsigned int) rctx->num_fresh_coins);
|
||||||
|
|
||||||
/* create fresh coin signatures */
|
/* create fresh coin signatures */
|
||||||
for (unsigned int i = 0; i<rctx->num_fresh_coins; i++)
|
|
||||||
{
|
{
|
||||||
|
struct TEH_CoinSignData csds[rctx->num_fresh_coins];
|
||||||
|
struct TALER_BlindedDenominationSignature bss[rctx->num_fresh_coins];
|
||||||
enum TALER_ErrorCode ec;
|
enum TALER_ErrorCode ec;
|
||||||
struct TEH_CoinSignData csd = {
|
|
||||||
.h_denom_pub = &rrcs[i].h_denom_pub,
|
|
||||||
.bp = &rcds[i].blinded_planchet
|
|
||||||
};
|
|
||||||
|
|
||||||
// FIXME #7272: replace with a batch call that
|
for (unsigned int i = 0; i<rctx->num_fresh_coins; i++)
|
||||||
// passes all coins in once go!
|
{
|
||||||
ec = TEH_keys_denomination_sign (
|
csds[i].h_denom_pub = &rrcs[i].h_denom_pub;
|
||||||
&csd,
|
csds[i].bp = &rcds[i].blinded_planchet;
|
||||||
|
}
|
||||||
|
ec = TEH_keys_denomination_batch_sign (
|
||||||
|
csds,
|
||||||
|
rctx->num_fresh_coins,
|
||||||
true,
|
true,
|
||||||
&rrcs[i].coin_sig);
|
bss);
|
||||||
if (TALER_EC_NONE != ec)
|
if (TALER_EC_NONE != ec)
|
||||||
{
|
{
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
@ -772,8 +773,9 @@ clean_age:
|
|||||||
NULL);
|
NULL);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
for (unsigned int i = 0; i<rctx->num_fresh_coins; i++)
|
||||||
|
rrcs[i].coin_sig = bss[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
|
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
|
||||||
"Signatures ready, starting DB interaction\n");
|
"Signatures ready, starting DB interaction\n");
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user