Skip to content

Commit 4eb5643

Browse files
committed
Convert everything except wallet/qt to new serialization
1 parent 2b1f85e commit 4eb5643

File tree

17 files changed

+71
-213
lines changed

17 files changed

+71
-213
lines changed

src/bench/prevector.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,7 @@
2020
struct nontrivial_t {
2121
int x;
2222
nontrivial_t() :x(-1) {}
23-
ADD_SERIALIZE_METHODS
24-
template <typename Stream, typename Operation>
25-
inline void SerializationOp(Stream& s, Operation ser_action) {READWRITE(x);}
23+
SERIALIZE_METHODS(nontrivial_t, obj) { READWRITE(obj.x); }
2624
};
2725
static_assert(!IS_TRIVIALLY_CONSTRUCTIBLE<nontrivial_t>::value,
2826
"expected nontrivial_t to not be trivially constructible");

src/bloom.h

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -66,15 +66,7 @@ class CBloomFilter
6666
CBloomFilter(const unsigned int nElements, const double nFPRate, const unsigned int nTweak, unsigned char nFlagsIn);
6767
CBloomFilter() : isFull(true), isEmpty(false), nHashFuncs(0), nTweak(0), nFlags(0) {}
6868

69-
ADD_SERIALIZE_METHODS;
70-
71-
template <typename Stream, typename Operation>
72-
inline void SerializationOp(Stream& s, Operation ser_action) {
73-
READWRITE(vData);
74-
READWRITE(nHashFuncs);
75-
READWRITE(nTweak);
76-
READWRITE(nFlags);
77-
}
69+
SERIALIZE_METHODS(CBloomFilter, obj) { READWRITE(obj.vData, obj.nHashFuncs, obj.nTweak, obj.nFlags); }
7870

7971
void insert(const std::vector<unsigned char>& vKey);
8072
void insert(const COutPoint& outpoint);

src/flatfile.h

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,7 @@ struct FlatFilePos
1616
int nFile;
1717
unsigned int nPos;
1818

19-
ADD_SERIALIZE_METHODS;
20-
21-
template <typename Stream, typename Operation>
22-
inline void SerializationOp(Stream& s, Operation ser_action) {
23-
READWRITE(VARINT_MODE(nFile, VarIntMode::NONNEGATIVE_SIGNED));
24-
READWRITE(VARINT(nPos));
25-
}
19+
SERIALIZE_METHODS(FlatFilePos, obj) { READWRITE(VARINT_MODE(obj.nFile, VarIntMode::NONNEGATIVE_SIGNED), VARINT(obj.nPos)); }
2620

2721
FlatFilePos() : nFile(-1), nPos(0) {}
2822

src/index/blockfilterindex.cpp

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,7 @@ struct DBVal {
3939
uint256 header;
4040
FlatFilePos pos;
4141

42-
ADD_SERIALIZE_METHODS;
43-
44-
template <typename Stream, typename Operation>
45-
inline void SerializationOp(Stream& s, Operation ser_action) {
46-
READWRITE(hash);
47-
READWRITE(header);
48-
READWRITE(pos);
49-
}
42+
SERIALIZE_METHODS(DBVal, obj) { READWRITE(obj.hash, obj.header, obj.pos); }
5043
};
5144

5245
struct DBHeightKey {
@@ -78,17 +71,14 @@ struct DBHashKey {
7871

7972
explicit DBHashKey(const uint256& hash_in) : hash(hash_in) {}
8073

81-
ADD_SERIALIZE_METHODS;
82-
83-
template <typename Stream, typename Operation>
84-
inline void SerializationOp(Stream& s, Operation ser_action) {
74+
SERIALIZE_METHODS(DBHashKey, obj) {
8575
char prefix = DB_BLOCK_HASH;
8676
READWRITE(prefix);
8777
if (prefix != DB_BLOCK_HASH) {
8878
throw std::ios_base::failure("Invalid format for block filter index DB hash key");
8979
}
9080

91-
READWRITE(hash);
81+
READWRITE(obj.hash);
9282
}
9383
};
9484

src/index/txindex.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,10 @@ struct CDiskTxPos : public FlatFilePos
2121
{
2222
unsigned int nTxOffset; // after header
2323

24-
ADD_SERIALIZE_METHODS;
25-
26-
template <typename Stream, typename Operation>
27-
inline void SerializationOp(Stream& s, Operation ser_action) {
28-
READWRITEAS(FlatFilePos, *this);
29-
READWRITE(VARINT(nTxOffset));
24+
SERIALIZE_METHODS(CDiskTxPos, obj)
25+
{
26+
READWRITEAS(FlatFilePos, obj);
27+
READWRITE(VARINT(obj.nTxOffset));
3028
}
3129

3230
CDiskTxPos(const FlatFilePos &blockIn, unsigned int nTxOffsetIn) : FlatFilePos(blockIn.nFile, blockIn.nPos), nTxOffset(nTxOffsetIn) {

src/netaddress.h

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,7 @@ class CNetAddr
9999
friend bool operator!=(const CNetAddr& a, const CNetAddr& b) { return !(a == b); }
100100
friend bool operator<(const CNetAddr& a, const CNetAddr& b);
101101

102-
ADD_SERIALIZE_METHODS;
103-
104-
template <typename Stream, typename Operation>
105-
inline void SerializationOp(Stream& s, Operation ser_action) {
106-
READWRITE(ip);
107-
}
102+
SERIALIZE_METHODS(CNetAddr, obj) { READWRITE(obj.ip); }
108103

109104
friend class CSubNet;
110105
};
@@ -136,14 +131,7 @@ class CSubNet
136131
friend bool operator!=(const CSubNet& a, const CSubNet& b) { return !(a == b); }
137132
friend bool operator<(const CSubNet& a, const CSubNet& b);
138133

139-
ADD_SERIALIZE_METHODS;
140-
141-
template <typename Stream, typename Operation>
142-
inline void SerializationOp(Stream& s, Operation ser_action) {
143-
READWRITE(network);
144-
READWRITE(netmask);
145-
READWRITE(valid);
146-
}
134+
SERIALIZE_METHODS(CSubNet, obj) { READWRITE(obj.network, obj.netmask, obj.valid); }
147135
};
148136

149137
/** A combination of a network address (CNetAddr) and a (TCP) port */
@@ -171,13 +159,7 @@ class CService : public CNetAddr
171159
CService(const struct in6_addr& ipv6Addr, unsigned short port);
172160
explicit CService(const struct sockaddr_in6& addr);
173161

174-
ADD_SERIALIZE_METHODS;
175-
176-
template <typename Stream, typename Operation>
177-
inline void SerializationOp(Stream& s, Operation ser_action) {
178-
READWRITE(ip);
179-
READWRITE(Using<BigEndianFormatter<2>>(port));
180-
}
162+
SERIALIZE_METHODS(CService, obj) { READWRITE(obj.ip, Using<BigEndianFormatter<2>>(obj.port)); }
181163
};
182164

183165
#endif // BITCOIN_NETADDRESS_H

src/node/utxo_snapshot.h

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,7 @@ class SnapshotMetadata
3535
m_coins_count(coins_count),
3636
m_nchaintx(nchaintx) { }
3737

38-
ADD_SERIALIZE_METHODS;
39-
40-
template <typename Stream, typename Operation>
41-
inline void SerializationOp(Stream& s, Operation ser_action)
42-
{
43-
READWRITE(m_base_blockhash);
44-
READWRITE(m_coins_count);
45-
READWRITE(m_nchaintx);
46-
}
47-
38+
SERIALIZE_METHODS(SnapshotMetadata, obj) { READWRITE(obj.m_base_blockhash, obj.m_coins_count, obj.m_nchaintx); }
4839
};
4940

5041
#endif // BITCOIN_NODE_UTXO_SNAPSHOT_H

src/policy/feerate.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,7 @@ class CFeeRate
4848
CFeeRate& operator+=(const CFeeRate& a) { nSatoshisPerK += a.nSatoshisPerK; return *this; }
4949
std::string ToString() const;
5050

51-
ADD_SERIALIZE_METHODS;
52-
53-
template <typename Stream, typename Operation>
54-
inline void SerializationOp(Stream& s, Operation ser_action) {
55-
READWRITE(nSatoshisPerK);
56-
}
51+
SERIALIZE_METHODS(CFeeRate, obj) { READWRITE(obj.nSatoshisPerK); }
5752
};
5853

5954
#endif // BITCOIN_POLICY_FEERATE_H

src/primitives/block.h

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,7 @@ class CBlockHeader
3333
SetNull();
3434
}
3535

36-
ADD_SERIALIZE_METHODS;
37-
38-
template <typename Stream, typename Operation>
39-
inline void SerializationOp(Stream& s, Operation ser_action) {
40-
READWRITE(this->nVersion);
41-
READWRITE(hashPrevBlock);
42-
READWRITE(hashMerkleRoot);
43-
READWRITE(nTime);
44-
READWRITE(nBits);
45-
READWRITE(nNonce);
46-
}
36+
SERIALIZE_METHODS(CBlockHeader, obj) { READWRITE(obj.nVersion, obj.hashPrevBlock, obj.hashMerkleRoot, obj.nTime, obj.nBits, obj.nNonce); }
4737

4838
void SetNull()
4939
{
@@ -89,12 +79,10 @@ class CBlock : public CBlockHeader
8979
*(static_cast<CBlockHeader*>(this)) = header;
9080
}
9181

92-
ADD_SERIALIZE_METHODS;
93-
94-
template <typename Stream, typename Operation>
95-
inline void SerializationOp(Stream& s, Operation ser_action) {
96-
READWRITEAS(CBlockHeader, *this);
97-
READWRITE(vtx);
82+
SERIALIZE_METHODS(CBlock, obj)
83+
{
84+
READWRITEAS(CBlockHeader, obj);
85+
READWRITE(obj.vtx);
9886
}
9987

10088
void SetNull()
@@ -131,14 +119,12 @@ struct CBlockLocator
131119

132120
explicit CBlockLocator(const std::vector<uint256>& vHaveIn) : vHave(vHaveIn) {}
133121

134-
ADD_SERIALIZE_METHODS;
135-
136-
template <typename Stream, typename Operation>
137-
inline void SerializationOp(Stream& s, Operation ser_action) {
122+
SERIALIZE_METHODS(CBlockLocator, obj)
123+
{
138124
int nVersion = s.GetVersion();
139125
if (!(s.GetType() & SER_GETHASH))
140126
READWRITE(nVersion);
141-
READWRITE(vHave);
127+
READWRITE(obj.vHave);
142128
}
143129

144130
void SetNull()

src/primitives/transaction.h

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,7 @@ class COutPoint
2626
COutPoint(): n(NULL_INDEX) { }
2727
COutPoint(const uint256& hashIn, uint32_t nIn): hash(hashIn), n(nIn) { }
2828

29-
ADD_SERIALIZE_METHODS;
30-
31-
template <typename Stream, typename Operation>
32-
inline void SerializationOp(Stream& s, Operation ser_action) {
33-
READWRITE(hash);
34-
READWRITE(n);
35-
}
29+
SERIALIZE_METHODS(COutPoint, obj) { READWRITE(obj.hash, obj.n); }
3630

3731
void SetNull() { hash.SetNull(); n = NULL_INDEX; }
3832
bool IsNull() const { return (hash.IsNull() && n == NULL_INDEX); }
@@ -103,14 +97,7 @@ class CTxIn
10397
explicit CTxIn(COutPoint prevoutIn, CScript scriptSigIn=CScript(), uint32_t nSequenceIn=SEQUENCE_FINAL);
10498
CTxIn(uint256 hashPrevTx, uint32_t nOut, CScript scriptSigIn=CScript(), uint32_t nSequenceIn=SEQUENCE_FINAL);
10599

106-
ADD_SERIALIZE_METHODS;
107-
108-
template <typename Stream, typename Operation>
109-
inline void SerializationOp(Stream& s, Operation ser_action) {
110-
READWRITE(prevout);
111-
READWRITE(scriptSig);
112-
READWRITE(nSequence);
113-
}
100+
SERIALIZE_METHODS(CTxIn, obj) { READWRITE(obj.prevout, obj.scriptSig, obj.nSequence); }
114101

115102
friend bool operator==(const CTxIn& a, const CTxIn& b)
116103
{
@@ -143,13 +130,7 @@ class CTxOut
143130

144131
CTxOut(const CAmount& nValueIn, CScript scriptPubKeyIn);
145132

146-
ADD_SERIALIZE_METHODS;
147-
148-
template <typename Stream, typename Operation>
149-
inline void SerializationOp(Stream& s, Operation ser_action) {
150-
READWRITE(nValue);
151-
READWRITE(scriptPubKey);
152-
}
133+
SERIALIZE_METHODS(CTxOut, obj) { READWRITE(obj.nValue, obj.scriptPubKey); }
153134

154135
void SetNull()
155136
{

0 commit comments

Comments
 (0)