Skip to content

Commit

Permalink
f'Add Elements-style witness serialization'
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenroose committed Feb 11, 2019
1 parent 0990de5 commit 94110a1
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 12 deletions.
1 change: 1 addition & 0 deletions src/bench/block_assemble.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ static void AssembleBlock(benchmark::State& state)
for (size_t b{0}; b < NUM_BLOCKS; ++b) {
CMutableTransaction tx;
tx.vin.push_back(MineBlock(SCRIPT_PUB));
tx.witness.vtxinwit.resize(1);
tx.witness.vtxinwit.back().scriptWitness = witness;
tx.vout.emplace_back(1337, SCRIPT_PUB);
if (NUM_BLOCKS - b >= COINBASE_MATURITY)
Expand Down
20 changes: 10 additions & 10 deletions src/bench/mempool_eviction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ static void MempoolEviction(benchmark::State& state)
CMutableTransaction tx2 = CMutableTransaction();
tx2.vin.resize(1);
tx2.vin[0].scriptSig = CScript() << OP_2;
tx1.witness.vtxinwit.resize(1);
tx2.witness.vtxinwit.resize(1);
tx2.witness.vtxinwit[0].scriptWitness.stack.push_back({2});
tx2.vout.resize(1);
tx2.vout[0].scriptPubKey = CScript() << OP_2 << OP_EQUAL;
Expand All @@ -51,7 +51,7 @@ static void MempoolEviction(benchmark::State& state)
tx3.vin.resize(1);
tx3.vin[0].prevout = COutPoint(tx2.GetHash(), 0);
tx3.vin[0].scriptSig = CScript() << OP_2;
tx1.witness.vtxinwit.resize(1);
tx3.witness.vtxinwit.resize(1);
tx3.witness.vtxinwit[0].scriptWitness.stack.push_back({3});
tx3.vout.resize(1);
tx3.vout[0].scriptPubKey = CScript() << OP_3 << OP_EQUAL;
Expand All @@ -61,11 +61,11 @@ static void MempoolEviction(benchmark::State& state)
tx4.vin.resize(2);
tx4.vin[0].prevout.SetNull();
tx4.vin[0].scriptSig = CScript() << OP_4;
tx1.witness.vtxinwit.resize(1);
tx4.witness.vtxinwit.resize(1);
tx4.witness.vtxinwit[0].scriptWitness.stack.push_back({4});
tx4.vin[1].prevout.SetNull();
tx4.vin[1].scriptSig = CScript() << OP_4;
tx1.witness.vtxinwit.resize(2);
tx4.witness.vtxinwit.resize(2);
tx4.witness.vtxinwit[1].scriptWitness.stack.push_back({4});
tx4.vout.resize(2);
tx4.vout[0].scriptPubKey = CScript() << OP_4 << OP_EQUAL;
Expand All @@ -77,11 +77,11 @@ static void MempoolEviction(benchmark::State& state)
tx5.vin.resize(2);
tx5.vin[0].prevout = COutPoint(tx4.GetHash(), 0);
tx5.vin[0].scriptSig = CScript() << OP_4;
tx1.witness.vtxinwit.resize(1);
tx5.witness.vtxinwit.resize(1);
tx5.witness.vtxinwit[0].scriptWitness.stack.push_back({4});
tx5.vin[1].prevout.SetNull();
tx5.vin[1].scriptSig = CScript() << OP_5;
tx1.witness.vtxinwit.resize(2);
tx5.witness.vtxinwit.resize(2);
tx5.witness.vtxinwit[1].scriptWitness.stack.push_back({5});
tx5.vout.resize(2);
tx5.vout[0].scriptPubKey = CScript() << OP_5 << OP_EQUAL;
Expand All @@ -93,11 +93,11 @@ static void MempoolEviction(benchmark::State& state)
tx6.vin.resize(2);
tx6.vin[0].prevout = COutPoint(tx4.GetHash(), 1);
tx6.vin[0].scriptSig = CScript() << OP_4;
tx1.witness.vtxinwit.resize(1);
tx6.witness.vtxinwit.resize(1);
tx6.witness.vtxinwit[0].scriptWitness.stack.push_back({4});
tx6.vin[1].prevout.SetNull();
tx6.vin[1].scriptSig = CScript() << OP_6;
tx1.witness.vtxinwit.resize(2);
tx6.witness.vtxinwit.resize(2);
tx6.witness.vtxinwit[1].scriptWitness.stack.push_back({6});
tx6.vout.resize(2);
tx6.vout[0].scriptPubKey = CScript() << OP_6 << OP_EQUAL;
Expand All @@ -109,11 +109,11 @@ static void MempoolEviction(benchmark::State& state)
tx7.vin.resize(2);
tx7.vin[0].prevout = COutPoint(tx5.GetHash(), 0);
tx7.vin[0].scriptSig = CScript() << OP_5;
tx1.witness.vtxinwit.resize(1);
tx7.witness.vtxinwit.resize(1);
tx7.witness.vtxinwit[0].scriptWitness.stack.push_back({5});
tx7.vin[1].prevout = COutPoint(tx6.GetHash(), 0);
tx7.vin[1].scriptSig = CScript() << OP_6;
tx1.witness.vtxinwit.resize(2);
tx7.witness.vtxinwit.resize(2);
tx7.witness.vtxinwit[1].scriptWitness.stack.push_back({6});
tx7.vout.resize(2);
tx7.vout[0].scriptPubKey = CScript() << OP_7 << OP_EQUAL;
Expand Down
2 changes: 1 addition & 1 deletion src/test/coins_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ BOOST_AUTO_TEST_CASE(updatecoins_simulation_test)
if (!tx.IsCoinBase()) {
const COutPoint &out = tx.vin[0].prevout;
Coin coin = undo.vprevout[0];
ApplyTxInUndo(std::move(coin), *(stack.back()), out, tx.vin[0], tx.witness.vtxinwit[0].m_pegin_witness);
ApplyTxInUndo(std::move(coin), *(stack.back()), out, tx.vin[0], CScriptWitness());
}
// Store as a candidate for reconnection
disconnected_coins.insert(utxod->first);
Expand Down
2 changes: 1 addition & 1 deletion src/wallet/feebumper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ Result CreateTransaction(const CWallet* wallet, const uint256& txid, const CCoin
wallet->WalletLogPrintf("Bumping fee and discarding dust output\n");
new_fee += poutput->nValue;
mtx.vout.erase(mtx.vout.begin() + nOutput);
if (mtx.witness.vtxoutwit.size() > nOutput) {
if (mtx.witness.vtxoutwit.size() > (size_t) nOutput) {
mtx.witness.vtxoutwit.erase(mtx.witness.vtxoutwit.begin() + nOutput);
}
}
Expand Down

0 comments on commit 94110a1

Please sign in to comment.