diff --git a/src/main.h b/src/main.h index 49004f3cd01f1..038f4e1b9f099 100644 --- a/src/main.h +++ b/src/main.h @@ -439,6 +439,7 @@ class PeerLogicValidation : public CValidationInterface { public: PeerLogicValidation(CConnman* connmanIn); + ~PeerLogicValidation() = default; virtual void UpdatedBlockTip(const CBlockIndex *pindexNew, const CBlockIndex *pindexFork, bool fInitialDownload); virtual void BlockChecked(const CBlock& block, const CValidationState& state); diff --git a/src/primitives/block.h b/src/primitives/block.h index c289eeb2eb017..fbbe92b893215 100644 --- a/src/primitives/block.h +++ b/src/primitives/block.h @@ -82,7 +82,7 @@ class CBlock : public CBlockHeader { public: // network and disk - std::vector> vtx; + std::vector vtx; // ppcoin: block signature - signed by one of the coin base txout[N]'s owner std::vector vchBlockSig; diff --git a/src/primitives/transaction.h b/src/primitives/transaction.h index f4ed12d3e3fed..3ca7d54db5f72 100644 --- a/src/primitives/transaction.h +++ b/src/primitives/transaction.h @@ -393,7 +393,7 @@ struct CMutableTransaction READWRITE(vout); READWRITE(nLockTime); - if (nVersion == CTransaction::SAPLING_VERSION) { + if (g_IsSaplingActive && nVersion == CTransaction::SAPLING_VERSION) { READWRITE(*const_cast*>(&sapData)); } } @@ -411,4 +411,10 @@ struct CMutableTransaction std::string ToString() const; }; +typedef std::shared_ptr CTransactionRef; +static inline CTransactionRef MakeTransactionRef() { return std::make_shared(); } +template static inline CTransactionRef MakeTransactionRef(Tx&& txIn) { return std::make_shared(std::forward(txIn)); } +static inline CTransactionRef MakeTransactionRef(const CTransactionRef& txIn) { return txIn; } +static inline CTransactionRef MakeTransactionRef(CTransactionRef&& txIn) { return std::move(txIn); } + #endif // BITCOIN_PRIMITIVES_TRANSACTION_H diff --git a/src/streams.h b/src/streams.h index 35866dea330cf..3e2c1f653d255 100644 --- a/src/streams.h +++ b/src/streams.h @@ -224,16 +224,15 @@ class CBaseDataStream // Read from the beginning of the buffer unsigned int nReadPosNext = nReadPos + nSize; - if (nReadPosNext >= vch.size()) { - if (nReadPosNext > vch.size()) { - throw std::ios_base::failure("CBaseDataStream::read() : end of data"); - } - memcpy(pch, &vch[nReadPos], nSize); + if (nReadPosNext > vch.size()) { + throw std::ios_base::failure("CDataStream::read(): end of data"); + } + memcpy(pch, &vch[nReadPos], nSize); + if (nReadPosNext == vch.size()) { nReadPos = 0; vch.clear(); return; } - memcpy(pch, &vch[nReadPos], nSize); nReadPos = nReadPosNext; } diff --git a/src/test/mempool_tests.cpp b/src/test/mempool_tests.cpp index 7f3dec4529a2f..c3e0501da218e 100644 --- a/src/test/mempool_tests.cpp +++ b/src/test/mempool_tests.cpp @@ -443,7 +443,7 @@ BOOST_AUTO_TEST_CASE(MempoolSizeLimitTest) pool.addUnchecked(tx5.GetHash(), entry.Fee(1000LL).FromTx(tx5, &pool)); pool.addUnchecked(tx7.GetHash(), entry.Fee(9000LL).FromTx(tx7, &pool)); - std::vector> vtx; + std::vector vtx; std::list conflicts; SetMockTime(42); SetMockTime(42 + CTxMemPool::ROLLING_FEE_HALFLIFE); diff --git a/src/test/merkle_tests.cpp b/src/test/merkle_tests.cpp index d9f1ac4e5a960..a0f33ae647904 100644 --- a/src/test/merkle_tests.cpp +++ b/src/test/merkle_tests.cpp @@ -15,7 +15,7 @@ static uint256 BlockBuildMerkleTree(const CBlock& block, bool* fMutated, std::ve { vMerkleTree.clear(); vMerkleTree.reserve(block.vtx.size() * 2 + 16); // Safe upper bound for the number of total nodes. - for (std::vector>::const_iterator it(block.vtx.begin()); it != block.vtx.end(); ++it) + for (std::vector::const_iterator it(block.vtx.begin()); it != block.vtx.end(); ++it) vMerkleTree.push_back((*it)->GetHash()); int j = 0; bool mutated = false; diff --git a/src/test/policyestimator_tests.cpp b/src/test/policyestimator_tests.cpp index bb3a65cb82603..aaacb62f41293 100644 --- a/src/test/policyestimator_tests.cpp +++ b/src/test/policyestimator_tests.cpp @@ -45,7 +45,7 @@ BOOST_AUTO_TEST_CASE(BlockPolicyEstimates) CFeeRate baseRate(basefee, ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION)); // Create a fake block - std::vector> block; + std::vector block; int blocknum = 0; // Loop through 200 blocks diff --git a/src/txmempool.cpp b/src/txmempool.cpp index 9a1c85d15b104..b67c8433fec6c 100644 --- a/src/txmempool.cpp +++ b/src/txmempool.cpp @@ -542,7 +542,7 @@ void CTxMemPool::removeConflicts(const CTransaction& tx, std::list /** * Called when a block is connected. Removes from mempool and updates the miner fee estimator. */ -void CTxMemPool::removeForBlock(const std::vector>& vtx, unsigned int nBlockHeight, std::list& conflicts, bool fCurrentEstimate) +void CTxMemPool::removeForBlock(const std::vector& vtx, unsigned int nBlockHeight, std::list& conflicts, bool fCurrentEstimate) { LOCK(cs); std::vector entries; diff --git a/src/txmempool.h b/src/txmempool.h index 8712660a0c6e9..09663ae95e069 100644 --- a/src/txmempool.h +++ b/src/txmempool.h @@ -478,7 +478,7 @@ class CTxMemPool void remove(const CTransaction& tx, std::list& removed, bool fRecursive = false); void removeForReorg(const CCoinsViewCache* pcoins, unsigned int nMemPoolHeight, int flags); void removeConflicts(const CTransaction& tx, std::list& removed); - void removeForBlock(const std::vector>& vtx, unsigned int nBlockHeight, std::list& conflicts, bool fCurrentEstimate = true); + void removeForBlock(const std::vector& vtx, unsigned int nBlockHeight, std::list& conflicts, bool fCurrentEstimate = true); void clear(); void _clear(); // lock-free void queryHashes(std::vector& vtxid);