aboutsummaryrefslogtreecommitdiff
path: root/src/main.h
diff options
context:
space:
mode:
authorPieter Wuille <pieter.wuille@gmail.com>2014-09-01 21:00:32 +0200
committerPieter Wuille <pieter.wuille@gmail.com>2014-09-01 21:23:01 +0200
commit2e731f24b5a5c894e013a6d752f1cd409303e916 (patch)
tree94ba6f1e3ab9ecb5ac1696b48b1aabc859aa8365 /src/main.h
parentf6a81050372810d8eebc15523bde28e91d045314 (diff)
parent31e9a8384a77947f6777d035992f4734618ed206 (diff)
Merge pull request #4737
31e9a83 Use CSizeComputer to avoid counting sizes in SerializationOp (Pieter Wuille) 84881f8 rework overhauled serialization methods to non-static (Kamil Domanski) 5d96b4a remove fields of ser_streamplaceholder (Kamil Domanski) 3d796f8 overhaul serialization code (Kamil Domanski)
Diffstat (limited to 'src/main.h')
-rw-r--r--src/main.h53
1 files changed, 37 insertions, 16 deletions
diff --git a/src/main.h b/src/main.h
index e0836960b3..31a1131b83 100644
--- a/src/main.h
+++ b/src/main.h
@@ -197,10 +197,13 @@ struct CDiskBlockPos
int nFile;
unsigned int nPos;
- IMPLEMENT_SERIALIZE(
+ IMPLEMENT_SERIALIZE;
+
+ template <typename Stream, typename Operation>
+ inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
READWRITE(VARINT(nFile));
READWRITE(VARINT(nPos));
- )
+ }
CDiskBlockPos() {
SetNull();
@@ -227,10 +230,13 @@ struct CDiskTxPos : public CDiskBlockPos
{
unsigned int nTxOffset; // after header
- IMPLEMENT_SERIALIZE(
+ IMPLEMENT_SERIALIZE;
+
+ template <typename Stream, typename Operation>
+ inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
READWRITE(*(CDiskBlockPos*)this);
READWRITE(VARINT(nTxOffset));
- )
+ }
CDiskTxPos(const CDiskBlockPos &blockIn, unsigned int nTxOffsetIn) : CDiskBlockPos(blockIn.nFile, blockIn.nPos), nTxOffset(nTxOffsetIn) {
}
@@ -307,9 +313,12 @@ class CBlockUndo
public:
std::vector<CTxUndo> vtxundo; // for all but the coinbase
- IMPLEMENT_SERIALIZE(
+ IMPLEMENT_SERIALIZE;
+
+ template <typename Stream, typename Operation>
+ inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
READWRITE(vtxundo);
- )
+ }
bool WriteToDisk(CDiskBlockPos &pos, const uint256 &hashBlock);
bool ReadFromDisk(const CDiskBlockPos &pos, const uint256 &hashBlock);
@@ -411,7 +420,12 @@ protected:
public:
// serialization implementation
- IMPLEMENT_SERIALIZE(
+ IMPLEMENT_SERIALIZE;
+
+ template <typename Stream, typename Operation>
+ inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
+ bool fRead = ser_action.ForRead();
+
READWRITE(nTransactions);
READWRITE(vHash);
std::vector<unsigned char> vBytes;
@@ -428,7 +442,7 @@ public:
vBytes[p / 8] |= vBits[p] << (p % 8);
READWRITE(vBytes);
}
- )
+ }
// Construct a partial merkle tree from a list of transaction id's, and a mask that selects a subset of them
CPartialMerkleTree(const std::vector<uint256> &vTxid, const std::vector<bool> &vMatch);
@@ -484,7 +498,10 @@ public:
uint64_t nTimeFirst; // earliest time of block in file
uint64_t nTimeLast; // latest time of block in file
- IMPLEMENT_SERIALIZE(
+ IMPLEMENT_SERIALIZE;
+
+ template <typename Stream, typename Operation>
+ inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
READWRITE(VARINT(nBlocks));
READWRITE(VARINT(nSize));
READWRITE(VARINT(nUndoSize));
@@ -492,7 +509,7 @@ public:
READWRITE(VARINT(nHeightLast));
READWRITE(VARINT(nTimeFirst));
READWRITE(VARINT(nTimeLast));
- )
+ }
void SetNull() {
nBlocks = 0;
@@ -755,8 +772,10 @@ public:
hashPrev = (pprev ? pprev->GetBlockHash() : 0);
}
- IMPLEMENT_SERIALIZE
- (
+ IMPLEMENT_SERIALIZE;
+
+ template <typename Stream, typename Operation>
+ inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
if (!(nType & SER_GETHASH))
READWRITE(VARINT(nVersion));
@@ -777,7 +796,7 @@ public:
READWRITE(nTime);
READWRITE(nBits);
READWRITE(nNonce);
- )
+ }
uint256 GetBlockHash() const
{
@@ -975,11 +994,13 @@ public:
// thus the filter will likely be modified.
CMerkleBlock(const CBlock& block, CBloomFilter& filter);
- IMPLEMENT_SERIALIZE
- (
+ IMPLEMENT_SERIALIZE;
+
+ template <typename Stream, typename Operation>
+ inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
READWRITE(header);
READWRITE(txn);
- )
+ }
};