diff options
author | Pieter Wuille <pieter.wuille@gmail.com> | 2014-06-07 13:53:27 +0200 |
---|---|---|
committer | Pieter Wuille <pieter.wuille@gmail.com> | 2014-06-21 22:59:03 +0200 |
commit | 4949004d68dc08382df2c34ae519c1b1cfd60f1a (patch) | |
tree | e3c4b2d6fa162af1cfbe44f6deb39278c12c5672 /src/test/miner_tests.cpp | |
parent | 8f59251b83cd9c862aee53dd50ce32bcab12ed6d (diff) |
Add CMutableTransaction and make CTransaction immutable.
In addition, introduce a cached hash inside CTransaction, to prevent
recalculating it over and over again.
Diffstat (limited to 'src/test/miner_tests.cpp')
-rw-r--r-- | src/test/miner_tests.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/test/miner_tests.cpp b/src/test/miner_tests.cpp index bff6de41a3..47977cf295 100644 --- a/src/test/miner_tests.cpp +++ b/src/test/miner_tests.cpp @@ -51,7 +51,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity) { CScript scriptPubKey = CScript() << ParseHex("04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f") << OP_CHECKSIG; CBlockTemplate *pblocktemplate; - CTransaction tx,tx2; + CMutableTransaction tx,tx2; CScript script; uint256 hash; @@ -68,10 +68,12 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity) CBlock *pblock = &pblocktemplate->block; // pointer for convenience pblock->nVersion = 1; pblock->nTime = chainActive.Tip()->GetMedianTimePast()+1; - pblock->vtx[0].vin[0].scriptSig = CScript(); - pblock->vtx[0].vin[0].scriptSig.push_back(blockinfo[i].extranonce); - pblock->vtx[0].vin[0].scriptSig.push_back(chainActive.Height()); - pblock->vtx[0].vout[0].scriptPubKey = CScript(); + CMutableTransaction txCoinbase(pblock->vtx[0]); + txCoinbase.vin[0].scriptSig = CScript(); + txCoinbase.vin[0].scriptSig.push_back(blockinfo[i].extranonce); + txCoinbase.vin[0].scriptSig.push_back(chainActive.Height()); + txCoinbase.vout[0].scriptPubKey = CScript(); + pblock->vtx[0] = CTransaction(txCoinbase); if (txFirst.size() < 2) txFirst.push_back(new CTransaction(pblock->vtx[0])); pblock->hashMerkleRoot = pblock->BuildMerkleTree(); |