mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-10 10:52:31 -05:00
Remove fUseWTXID parameter from CBlockHeaderAndShortTxIDs constructor
All uses of CBlockHeaderAndShortTxIDs in the product code are constructed with fUseWTXID=true, so remove the parameter. There is one use of the CBlockHeaderAndShortTxIDs constructor with fUseWTXID=false in the unit tests. This is used to construct a CBlockHeaderAndShortTxIDs for a block with only the coinbase transaction, so setting fUseWTXID to true or false makes no difference. Suggested in https://github.com/bitcoin/bitcoin/pull/20799#pullrequestreview-963480278
This commit is contained in:
parent
6b87fa540c
commit
c65bf50b44
4 changed files with 9 additions and 9 deletions
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
|
||||||
CBlockHeaderAndShortTxIDs::CBlockHeaderAndShortTxIDs(const CBlock& block, bool fUseWTXID) :
|
CBlockHeaderAndShortTxIDs::CBlockHeaderAndShortTxIDs(const CBlock& block) :
|
||||||
nonce(GetRand<uint64_t>()),
|
nonce(GetRand<uint64_t>()),
|
||||||
shorttxids(block.vtx.size() - 1), prefilledtxn(1), header(block) {
|
shorttxids(block.vtx.size() - 1), prefilledtxn(1), header(block) {
|
||||||
FillShortTxIDSelector();
|
FillShortTxIDSelector();
|
||||||
|
@ -24,7 +24,7 @@ CBlockHeaderAndShortTxIDs::CBlockHeaderAndShortTxIDs(const CBlock& block, bool f
|
||||||
prefilledtxn[0] = {0, block.vtx[0]};
|
prefilledtxn[0] = {0, block.vtx[0]};
|
||||||
for (size_t i = 1; i < block.vtx.size(); i++) {
|
for (size_t i = 1; i < block.vtx.size(); i++) {
|
||||||
const CTransaction& tx = *block.vtx[i];
|
const CTransaction& tx = *block.vtx[i];
|
||||||
shorttxids[i - 1] = GetShortID(fUseWTXID ? tx.GetWitnessHash() : tx.GetHash());
|
shorttxids[i - 1] = GetShortID(tx.GetWitnessHash());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -104,7 +104,7 @@ public:
|
||||||
// Dummy for deserialization
|
// Dummy for deserialization
|
||||||
CBlockHeaderAndShortTxIDs() {}
|
CBlockHeaderAndShortTxIDs() {}
|
||||||
|
|
||||||
CBlockHeaderAndShortTxIDs(const CBlock& block, bool fUseWTXID);
|
CBlockHeaderAndShortTxIDs(const CBlock& block);
|
||||||
|
|
||||||
uint64_t GetShortID(const uint256& txhash) const;
|
uint64_t GetShortID(const uint256& txhash) const;
|
||||||
|
|
||||||
|
|
|
@ -1632,7 +1632,7 @@ void PeerManagerImpl::BlockDisconnected(const std::shared_ptr<const CBlock> &blo
|
||||||
*/
|
*/
|
||||||
void PeerManagerImpl::NewPoWValidBlock(const CBlockIndex *pindex, const std::shared_ptr<const CBlock>& pblock)
|
void PeerManagerImpl::NewPoWValidBlock(const CBlockIndex *pindex, const std::shared_ptr<const CBlock>& pblock)
|
||||||
{
|
{
|
||||||
std::shared_ptr<const CBlockHeaderAndShortTxIDs> pcmpctblock = std::make_shared<const CBlockHeaderAndShortTxIDs> (*pblock, true);
|
auto pcmpctblock = std::make_shared<const CBlockHeaderAndShortTxIDs>(*pblock);
|
||||||
const CNetMsgMaker msgMaker(PROTOCOL_VERSION);
|
const CNetMsgMaker msgMaker(PROTOCOL_VERSION);
|
||||||
|
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
|
@ -1978,7 +1978,7 @@ void PeerManagerImpl::ProcessGetBlockData(CNode& pfrom, Peer& peer, const CInv&
|
||||||
if (a_recent_compact_block && a_recent_compact_block->header.GetHash() == pindex->GetBlockHash()) {
|
if (a_recent_compact_block && a_recent_compact_block->header.GetHash() == pindex->GetBlockHash()) {
|
||||||
m_connman.PushMessage(&pfrom, msgMaker.Make(NetMsgType::CMPCTBLOCK, *a_recent_compact_block));
|
m_connman.PushMessage(&pfrom, msgMaker.Make(NetMsgType::CMPCTBLOCK, *a_recent_compact_block));
|
||||||
} else {
|
} else {
|
||||||
CBlockHeaderAndShortTxIDs cmpctblock(*pblock, true);
|
CBlockHeaderAndShortTxIDs cmpctblock{*pblock};
|
||||||
m_connman.PushMessage(&pfrom, msgMaker.Make(NetMsgType::CMPCTBLOCK, cmpctblock));
|
m_connman.PushMessage(&pfrom, msgMaker.Make(NetMsgType::CMPCTBLOCK, cmpctblock));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -4771,7 +4771,7 @@ bool PeerManagerImpl::SendMessages(CNode* pto)
|
||||||
CBlock block;
|
CBlock block;
|
||||||
bool ret = ReadBlockFromDisk(block, pBestIndex, consensusParams);
|
bool ret = ReadBlockFromDisk(block, pBestIndex, consensusParams);
|
||||||
assert(ret);
|
assert(ret);
|
||||||
CBlockHeaderAndShortTxIDs cmpctblock(block, true);
|
CBlockHeaderAndShortTxIDs cmpctblock{block};
|
||||||
m_connman.PushMessage(pto, msgMaker.Make(NetMsgType::CMPCTBLOCK, cmpctblock));
|
m_connman.PushMessage(pto, msgMaker.Make(NetMsgType::CMPCTBLOCK, cmpctblock));
|
||||||
}
|
}
|
||||||
state.pindexBestHeaderSent = pBestIndex;
|
state.pindexBestHeaderSent = pBestIndex;
|
||||||
|
|
|
@ -64,7 +64,7 @@ BOOST_AUTO_TEST_CASE(SimpleRoundTripTest)
|
||||||
|
|
||||||
// Do a simple ShortTxIDs RT
|
// Do a simple ShortTxIDs RT
|
||||||
{
|
{
|
||||||
CBlockHeaderAndShortTxIDs shortIDs(block, true);
|
CBlockHeaderAndShortTxIDs shortIDs{block};
|
||||||
|
|
||||||
CDataStream stream(SER_NETWORK, PROTOCOL_VERSION);
|
CDataStream stream(SER_NETWORK, PROTOCOL_VERSION);
|
||||||
stream << shortIDs;
|
stream << shortIDs;
|
||||||
|
@ -122,7 +122,7 @@ public:
|
||||||
stream >> *this;
|
stream >> *this;
|
||||||
}
|
}
|
||||||
explicit TestHeaderAndShortIDs(const CBlock& block) :
|
explicit TestHeaderAndShortIDs(const CBlock& block) :
|
||||||
TestHeaderAndShortIDs(CBlockHeaderAndShortTxIDs(block, true)) {}
|
TestHeaderAndShortIDs(CBlockHeaderAndShortTxIDs{block}) {}
|
||||||
|
|
||||||
uint64_t GetShortID(const uint256& txhash) const {
|
uint64_t GetShortID(const uint256& txhash) const {
|
||||||
CDataStream stream(SER_NETWORK, PROTOCOL_VERSION);
|
CDataStream stream(SER_NETWORK, PROTOCOL_VERSION);
|
||||||
|
@ -279,7 +279,7 @@ BOOST_AUTO_TEST_CASE(EmptyBlockRoundTripTest)
|
||||||
|
|
||||||
// Test simple header round-trip with only coinbase
|
// Test simple header round-trip with only coinbase
|
||||||
{
|
{
|
||||||
CBlockHeaderAndShortTxIDs shortIDs(block, false);
|
CBlockHeaderAndShortTxIDs shortIDs{block};
|
||||||
|
|
||||||
CDataStream stream(SER_NETWORK, PROTOCOL_VERSION);
|
CDataStream stream(SER_NETWORK, PROTOCOL_VERSION);
|
||||||
stream << shortIDs;
|
stream << shortIDs;
|
||||||
|
|
Loading…
Add table
Reference in a new issue