Skip to content

Commit 312da73

Browse files
committed
change serialize and deserialize option for auxpow
1 parent d6808a6 commit 312da73

File tree

2 files changed

+32
-6
lines changed

2 files changed

+32
-6
lines changed

src/auxpow.h

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@ class CAuxPow
8484
CAuxPow (const CAuxPow&) = delete;
8585
void operator= (const CAuxPow&) = delete;
8686

87-
SERIALIZE_METHODS (CAuxPow, obj)
87+
template <typename Stream>
88+
void Serialize(Stream& s) const
8889
{
8990
/* The coinbase Merkle tx' hashBlock field is never actually verified
9091
or used in the code for an auxpow (and never was). The parent block
@@ -96,12 +97,38 @@ class CAuxPow
9697
/* The index of the parent coinbase tx is always zero. */
9798
int nIndex = 0;
9899

99-
/* Data from the coinbase transaction as Merkle tx. */
100-
READWRITE (Sidechain::Bitcoin::TX_WITH_WITNESS(obj.coinbaseTx), hashBlock,
101-
obj.vMerkleBranch, nIndex);
100+
/* Serialize the coinbase transaction with witness data. */
101+
s << Sidechain::Bitcoin::TX_WITH_WITNESS(*coinbaseTx);
102+
s << hashBlock;
103+
s << vMerkleBranch;
104+
s << nIndex;
102105

103106
/* Additional data for the auxpow itself. */
104-
READWRITE (obj.vChainMerkleBranch, obj.nChainIndex, obj.parentBlock);
107+
s << vChainMerkleBranch;
108+
s << nChainIndex;
109+
s << parentBlock;
110+
}
111+
112+
template <typename Stream>
113+
void Unserialize(Stream& s)
114+
{
115+
uint256 hashBlock;
116+
int nIndex = 0;
117+
118+
/* Deserialize the coinbase transaction.
119+
We read into a mutable transaction first, then convert to CTransactionRef. */
120+
Sidechain::Bitcoin::CMutableTransaction mtx;
121+
s >> Sidechain::Bitcoin::TX_WITH_WITNESS(mtx);
122+
coinbaseTx = Sidechain::Bitcoin::MakeTransactionRef(std::move(mtx));
123+
124+
s >> hashBlock;
125+
s >> vMerkleBranch;
126+
s >> nIndex;
127+
128+
/* Additional data for the auxpow itself. */
129+
s >> vChainMerkleBranch;
130+
s >> nChainIndex;
131+
s >> parentBlock;
105132
}
106133

107134
/**

src/net_processing.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4736,7 +4736,6 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
47364736

47374737
if (msg_type == NetMsgType::HEADERS)
47384738
{
4739-
LogPrintf("testing vRecv >> headers 1 \n");
47404739
// Ignore headers received while importing
47414740
if (m_chainman.m_blockman.LoadingBlocks()) {
47424741
LogDebug(BCLog::NET, "Unexpected headers message received from peer %d\n", pfrom.GetId());

0 commit comments

Comments
 (0)