Convert chain to new serialization

This commit is contained in:
Pieter Wuille 2017-07-07 20:27:39 -07:00
parent 2f1b2f4ed0
commit 9b66083788

View file

@ -48,17 +48,15 @@ public:
uint64_t nTimeFirst; //!< earliest time of block in file uint64_t nTimeFirst; //!< earliest time of block in file
uint64_t nTimeLast; //!< latest time of block in file uint64_t nTimeLast; //!< latest time of block in file
ADD_SERIALIZE_METHODS; SERIALIZE_METHODS(CBlockFileInfo, obj)
{
template <typename Stream, typename Operation> READWRITE(VARINT(obj.nBlocks));
inline void SerializationOp(Stream& s, Operation ser_action) { READWRITE(VARINT(obj.nSize));
READWRITE(VARINT(nBlocks)); READWRITE(VARINT(obj.nUndoSize));
READWRITE(VARINT(nSize)); READWRITE(VARINT(obj.nHeightFirst));
READWRITE(VARINT(nUndoSize)); READWRITE(VARINT(obj.nHeightLast));
READWRITE(VARINT(nHeightFirst)); READWRITE(VARINT(obj.nTimeFirst));
READWRITE(VARINT(nHeightLast)); READWRITE(VARINT(obj.nTimeLast));
READWRITE(VARINT(nTimeFirst));
READWRITE(VARINT(nTimeLast));
} }
void SetNull() { void SetNull() {
@ -332,31 +330,25 @@ public:
hashPrev = (pprev ? pprev->GetBlockHash() : uint256()); hashPrev = (pprev ? pprev->GetBlockHash() : uint256());
} }
ADD_SERIALIZE_METHODS; SERIALIZE_METHODS(CDiskBlockIndex, obj)
{
template <typename Stream, typename Operation>
inline void SerializationOp(Stream& s, Operation ser_action) {
int _nVersion = s.GetVersion(); int _nVersion = s.GetVersion();
if (!(s.GetType() & SER_GETHASH)) if (!(s.GetType() & SER_GETHASH)) READWRITE(VARINT(_nVersion, VarIntMode::NONNEGATIVE_SIGNED));
READWRITE(VARINT(_nVersion, VarIntMode::NONNEGATIVE_SIGNED));
READWRITE(VARINT(nHeight, VarIntMode::NONNEGATIVE_SIGNED)); READWRITE(VARINT(obj.nHeight, VarIntMode::NONNEGATIVE_SIGNED));
READWRITE(VARINT(nStatus)); READWRITE(VARINT(obj.nStatus));
READWRITE(VARINT(nTx)); READWRITE(VARINT(obj.nTx));
if (nStatus & (BLOCK_HAVE_DATA | BLOCK_HAVE_UNDO)) if (obj.nStatus & (BLOCK_HAVE_DATA | BLOCK_HAVE_UNDO)) READWRITE(VARINT(obj.nFile, VarIntMode::NONNEGATIVE_SIGNED));
READWRITE(VARINT(nFile, VarIntMode::NONNEGATIVE_SIGNED)); if (obj.nStatus & BLOCK_HAVE_DATA) READWRITE(VARINT(obj.nDataPos));
if (nStatus & BLOCK_HAVE_DATA) if (obj.nStatus & BLOCK_HAVE_UNDO) READWRITE(VARINT(obj.nUndoPos));
READWRITE(VARINT(nDataPos));
if (nStatus & BLOCK_HAVE_UNDO)
READWRITE(VARINT(nUndoPos));
// block header // block header
READWRITE(this->nVersion); READWRITE(obj.nVersion);
READWRITE(hashPrev); READWRITE(obj.hashPrev);
READWRITE(hashMerkleRoot); READWRITE(obj.hashMerkleRoot);
READWRITE(nTime); READWRITE(obj.nTime);
READWRITE(nBits); READWRITE(obj.nBits);
READWRITE(nNonce); READWRITE(obj.nNonce);
} }
uint256 GetBlockHash() const uint256 GetBlockHash() const