Skip to content

Commit f75149b

Browse files
committed
Lift create_seeded_transaction outside hot loop
Also includes modifying twophase mode's transaction-creation to reuse pedersen-commitments/range-proofs Signed-off-by: Sam Stuewe <[email protected]>
1 parent 91b0846 commit f75149b

File tree

1 file changed

+19
-18
lines changed

1 file changed

+19
-18
lines changed

tools/shard-seeder/shard-seeder.cpp

+19-18
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,24 @@ auto main(int argc, char** argv) -> int {
128128
" to database ",
129129
shard_db_dir.str());
130130

131+
auto value = cbdc::commit(secp_context.get(),
132+
cfg.m_seed_value,
133+
{})
134+
.value();
135+
auto range
136+
= cbdc::transaction::prove(secp_context.get(),
137+
bulletproof_gens.get(),
138+
rng,
139+
{{}, cfg.m_seed_value},
140+
&value);
141+
auto value_comm
142+
= cbdc::serialize_commitment(secp_context.get(),
143+
value);
144+
145+
auto tx = wal.create_seeded_transaction(0,
146+
value_comm,
147+
range)
148+
.value();
131149
if(!cfg.m_twophase_mode) {
132150
leveldb::Options opt;
133151
opt.create_if_missing = true;
@@ -150,24 +168,8 @@ auto main(int argc, char** argv) -> int {
150168
}
151169
auto batch_size = 0;
152170
leveldb::WriteBatch batch;
153-
auto value = cbdc::commit(secp_context.get(),
154-
cfg.m_seed_value,
155-
{})
156-
.value();
157-
auto range
158-
= cbdc::transaction::prove(secp_context.get(),
159-
bulletproof_gens.get(),
160-
rng,
161-
{{}, cfg.m_seed_value},
162-
&value);
163-
auto value_comm
164-
= cbdc::serialize_commitment(secp_context.get(),
165-
value);
166171
for(size_t tx_idx = 0; tx_idx != num_utxos; tx_idx++) {
167-
auto tx = wal.create_seeded_transaction(tx_idx,
168-
value_comm,
169-
range)
170-
.value();
172+
tx.m_inputs[0].m_prevout.m_index = tx_idx;
171173
cbdc::transaction::compact_tx ctx(tx);
172174
const cbdc::hash_t& output_hash
173175
= cbdc::transaction::calculate_uhs_id(
@@ -215,7 +217,6 @@ auto main(int argc, char** argv) -> int {
215217
// write dummy size
216218
auto ser = cbdc::ostream_serializer(out);
217219
ser << count;
218-
auto tx = wal.create_seeded_transaction(0).value();
219220
for(size_t tx_idx = 0; tx_idx != num_utxos; tx_idx++) {
220221
tx.m_inputs[0].m_prevout.m_index = tx_idx;
221222
cbdc::transaction::compact_tx ctx(tx);

0 commit comments

Comments
 (0)