Changeset View
Changeset View
Standalone View
Standalone View
src/test/blockencodings_tests.cpp
Show First 20 Lines • Show All 127 Lines • ▼ Show 20 Lines | |||||
class TestHeaderAndShortIDs { | class TestHeaderAndShortIDs { | ||||
// Utility to encode custom CBlockHeaderAndShortTxIDs | // Utility to encode custom CBlockHeaderAndShortTxIDs | ||||
public: | public: | ||||
CBlockHeader header; | CBlockHeader header; | ||||
uint64_t nonce; | uint64_t nonce; | ||||
std::vector<uint64_t> shorttxids; | std::vector<uint64_t> shorttxids; | ||||
std::vector<PrefilledTransaction> prefilledtxn; | std::vector<PrefilledTransaction> prefilledtxn; | ||||
TestHeaderAndShortIDs(const CBlockHeaderAndShortTxIDs &orig) { | explicit TestHeaderAndShortIDs(const CBlockHeaderAndShortTxIDs &orig) { | ||||
CDataStream stream(SER_NETWORK, PROTOCOL_VERSION); | CDataStream stream(SER_NETWORK, PROTOCOL_VERSION); | ||||
stream << orig; | stream << orig; | ||||
stream >> *this; | stream >> *this; | ||||
} | } | ||||
TestHeaderAndShortIDs(const CBlock &block) | explicit TestHeaderAndShortIDs(const CBlock &block) | ||||
: TestHeaderAndShortIDs(CBlockHeaderAndShortTxIDs(block)) {} | : 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); | ||||
stream << *this; | stream << *this; | ||||
CBlockHeaderAndShortTxIDs base; | CBlockHeaderAndShortTxIDs base; | ||||
stream >> base; | stream >> base; | ||||
return base.GetShortID(txhash); | return base.GetShortID(txhash); | ||||
▲ Show 20 Lines • Show All 239 Lines • Show Last 20 Lines |