Skip to content

Commit

Permalink
Lift create_seeded_transaction outside hot loop
Browse files Browse the repository at this point in the history
Also includes modifying twophase mode's transaction-creation
to reuse pedersen-commitments/range-proofs

Signed-off-by: Sam Stuewe <[email protected]>
  • Loading branch information
HalosGhost committed Oct 21, 2022
1 parent 91b0846 commit f75149b
Showing 1 changed file with 19 additions and 18 deletions.
37 changes: 19 additions & 18 deletions tools/shard-seeder/shard-seeder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,24 @@ auto main(int argc, char** argv) -> int {
" to database ",
shard_db_dir.str());

auto value = cbdc::commit(secp_context.get(),
cfg.m_seed_value,
{})
.value();
auto range
= cbdc::transaction::prove(secp_context.get(),
bulletproof_gens.get(),
rng,
{{}, cfg.m_seed_value},
&value);
auto value_comm
= cbdc::serialize_commitment(secp_context.get(),
value);

auto tx = wal.create_seeded_transaction(0,
value_comm,
range)
.value();
if(!cfg.m_twophase_mode) {
leveldb::Options opt;
opt.create_if_missing = true;
Expand All @@ -150,24 +168,8 @@ auto main(int argc, char** argv) -> int {
}
auto batch_size = 0;
leveldb::WriteBatch batch;
auto value = cbdc::commit(secp_context.get(),
cfg.m_seed_value,
{})
.value();
auto range
= cbdc::transaction::prove(secp_context.get(),
bulletproof_gens.get(),
rng,
{{}, cfg.m_seed_value},
&value);
auto value_comm
= cbdc::serialize_commitment(secp_context.get(),
value);
for(size_t tx_idx = 0; tx_idx != num_utxos; tx_idx++) {
auto tx = wal.create_seeded_transaction(tx_idx,
value_comm,
range)
.value();
tx.m_inputs[0].m_prevout.m_index = tx_idx;
cbdc::transaction::compact_tx ctx(tx);
const cbdc::hash_t& output_hash
= cbdc::transaction::calculate_uhs_id(
Expand Down Expand Up @@ -215,7 +217,6 @@ auto main(int argc, char** argv) -> int {
// write dummy size
auto ser = cbdc::ostream_serializer(out);
ser << count;
auto tx = wal.create_seeded_transaction(0).value();
for(size_t tx_idx = 0; tx_idx != num_utxos; tx_idx++) {
tx.m_inputs[0].m_prevout.m_index = tx_idx;
cbdc::transaction::compact_tx ctx(tx);
Expand Down

0 comments on commit f75149b

Please sign in to comment.