aboutsummaryrefslogtreecommitdiff
path: root/src/validation.cpp
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2016-12-05 08:01:20 +0100
committerWladimir J. van der Laan <laanwj@gmail.com>2016-12-05 08:05:48 +0100
commit46904ee5d2ce867b522a582b23e1ac6735179e5c (patch)
treeac8c79733afef5eb6dff533ec867165d968d2b12 /src/validation.cpp
parent4d955fc5824b1891ea082f5ebdfa5473e37323ca (diff)
parent81e3228fcb33e8ed32d8b9fbe917444ba080073a (diff)
Merge #8580: Make CTransaction actually immutable
81e3228 Make CTransaction actually immutable (Pieter Wuille) 42fd8de Make DecodeHexTx return a CMutableTransaction (Pieter Wuille) c3f5673 Make CWalletTx store a CTransactionRef instead of inheriting (Pieter Wuille) a188353 Switch GetTransaction to returning a CTransactionRef (Pieter Wuille)
Diffstat (limited to 'src/validation.cpp')
-rw-r--r--src/validation.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/validation.cpp b/src/validation.cpp
index 9cfb5221a6..7eef14af2b 100644
--- a/src/validation.cpp
+++ b/src/validation.cpp
@@ -984,7 +984,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa
}
/** Return transaction in txOut, and if it was found inside a block, its hash is placed in hashBlock */
-bool GetTransaction(const uint256 &hash, CTransaction &txOut, const Consensus::Params& consensusParams, uint256 &hashBlock, bool fAllowSlow)
+bool GetTransaction(const uint256 &hash, CTransactionRef &txOut, const Consensus::Params& consensusParams, uint256 &hashBlock, bool fAllowSlow)
{
CBlockIndex *pindexSlow = NULL;
@@ -993,7 +993,7 @@ bool GetTransaction(const uint256 &hash, CTransaction &txOut, const Consensus::P
CTransactionRef ptx = mempool.get(hash);
if (ptx)
{
- txOut = *ptx;
+ txOut = ptx;
return true;
}
@@ -1012,7 +1012,7 @@ bool GetTransaction(const uint256 &hash, CTransaction &txOut, const Consensus::P
return error("%s: Deserialize or I/O error - %s", __func__, e.what());
}
hashBlock = header.GetHash();
- if (txOut.GetHash() != hash)
+ if (txOut->GetHash() != hash)
return error("%s: txid mismatch", __func__);
return true;
}
@@ -1035,7 +1035,7 @@ bool GetTransaction(const uint256 &hash, CTransaction &txOut, const Consensus::P
if (ReadBlockFromDisk(block, pindexSlow, consensusParams)) {
for (const auto& tx : block.vtx) {
if (tx->GetHash() == hash) {
- txOut = *tx;
+ txOut = tx;
hashBlock = pindexSlow->GetBlockHash();
return true;
}
@@ -2859,8 +2859,9 @@ std::vector<unsigned char> GenerateCoinbaseCommitment(CBlock& block, const CBloc
out.scriptPubKey[5] = 0xed;
memcpy(&out.scriptPubKey[6], witnessroot.begin(), 32);
commitment = std::vector<unsigned char>(out.scriptPubKey.begin(), out.scriptPubKey.end());
- const_cast<std::vector<CTxOut>*>(&block.vtx[0]->vout)->push_back(out);
- block.vtx[0]->UpdateHash();
+ CMutableTransaction tx(*block.vtx[0]);
+ tx.vout.push_back(out);
+ block.vtx[0] = MakeTransactionRef(std::move(tx));
}
}
UpdateUncommittedBlockStructures(block, pindexPrev, consensusParams);
@@ -4090,10 +4091,9 @@ bool LoadMempool(void)
file >> num;
double prioritydummy = 0;
while (num--) {
- CTransaction tx;
int64_t nTime;
int64_t nFeeDelta;
- file >> tx;
+ CTransaction tx(deserialize, file);
file >> nTime;
file >> nFeeDelta;