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 24, 2022
1 parent 91b0846 commit 3c6a4c3
Showing 1 changed file with 2 additions and 18 deletions.
20 changes: 2 additions & 18 deletions tools/shard-seeder/shard-seeder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ auto main(int argc, char** argv) -> int {
" to database ",
shard_db_dir.str());

auto tx = wal.create_seeded_transaction(0).value();
if(!cfg.m_twophase_mode) {
leveldb::Options opt;
opt.create_if_missing = true;
Expand All @@ -150,24 +151,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 +200,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 3c6a4c3

Please sign in to comment.