aboutsummaryrefslogtreecommitdiff
path: root/src/core.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/core.h')
-rw-r--r--src/core.h87
1 files changed, 62 insertions, 25 deletions
diff --git a/src/core.h b/src/core.h
index a3ec2346e2..34c00c4142 100644
--- a/src/core.h
+++ b/src/core.h
@@ -30,7 +30,14 @@ public:
COutPoint() { SetNull(); }
COutPoint(uint256 hashIn, uint32_t nIn) { hash = hashIn; n = nIn; }
- IMPLEMENT_SERIALIZE( READWRITE(FLATDATA(*this)); )
+
+ IMPLEMENT_SERIALIZE;
+
+ template <typename Stream, typename Operation>
+ inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
+ READWRITE(FLATDATA(*this));
+ }
+
void SetNull() { hash = 0; n = (uint32_t) -1; }
bool IsNull() const { return (hash == 0 && n == (uint32_t) -1); }
@@ -84,12 +91,14 @@ public:
explicit CTxIn(COutPoint prevoutIn, CScript scriptSigIn=CScript(), uint32_t nSequenceIn=std::numeric_limits<unsigned int>::max());
CTxIn(uint256 hashPrevTx, uint32_t nOut, CScript scriptSigIn=CScript(), uint32_t nSequenceIn=std::numeric_limits<uint32_t>::max());
- IMPLEMENT_SERIALIZE
- (
+ IMPLEMENT_SERIALIZE;
+
+ template <typename Stream, typename Operation>
+ inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
READWRITE(prevout);
READWRITE(scriptSig);
READWRITE(nSequence);
- )
+ }
bool IsFinal() const
{
@@ -136,7 +145,12 @@ public:
friend bool operator>=(const CFeeRate& a, const CFeeRate& b) { return a.nSatoshisPerK >= b.nSatoshisPerK; }
std::string ToString() const;
- IMPLEMENT_SERIALIZE( READWRITE(nSatoshisPerK); )
+ IMPLEMENT_SERIALIZE;
+
+ template <typename Stream, typename Operation>
+ inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
+ READWRITE(nSatoshisPerK);
+ }
};
@@ -156,11 +170,13 @@ public:
CTxOut(int64_t nValueIn, CScript scriptPubKeyIn);
- IMPLEMENT_SERIALIZE
- (
+ IMPLEMENT_SERIALIZE;
+
+ template <typename Stream, typename Operation>
+ inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
READWRITE(nValue);
READWRITE(scriptPubKey);
- )
+ }
void SetNull()
{
@@ -237,7 +253,12 @@ public:
CTransaction& operator=(const CTransaction& tx);
- 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(*const_cast<int32_t*>(&this->nVersion));
nVersion = this->nVersion;
READWRITE(*const_cast<std::vector<CTxIn>*>(&vin));
@@ -245,7 +266,7 @@ public:
READWRITE(*const_cast<uint32_t*>(&nLockTime));
if (fRead)
UpdateHash();
- )
+ }
bool IsNull() const {
return vin.empty() && vout.empty();
@@ -292,13 +313,16 @@ struct CMutableTransaction
CMutableTransaction();
CMutableTransaction(const CTransaction& tx);
- IMPLEMENT_SERIALIZE(
+ IMPLEMENT_SERIALIZE;
+
+ template <typename Stream, typename Operation>
+ inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
READWRITE(this->nVersion);
nVersion = this->nVersion;
READWRITE(vin);
READWRITE(vout);
READWRITE(nLockTime);
- )
+ }
/** Compute the hash of this CMutableTransaction. This is computed on the
* fly, as opposed to GetHash() in CTransaction, which uses a cached result.
@@ -318,7 +342,11 @@ public:
CTxOutCompressor(CTxOut &txoutIn) : txout(txoutIn) { }
- 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();
if (!fRead) {
uint64_t nVal = CompressAmount(txout.nValue);
READWRITE(VARINT(nVal));
@@ -329,7 +357,7 @@ public:
}
CScriptCompressor cscript(REF(txout.scriptPubKey));
READWRITE(cscript);
- });)
+ }
};
/** Undo information for a CTxIn
@@ -382,9 +410,12 @@ public:
// undo information for all txins
std::vector<CTxInUndo> vprevout;
- IMPLEMENT_SERIALIZE(
+ IMPLEMENT_SERIALIZE;
+
+ template <typename Stream, typename Operation>
+ inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
READWRITE(vprevout);
- )
+ }
};
@@ -412,8 +443,10 @@ public:
SetNull();
}
- IMPLEMENT_SERIALIZE
- (
+ IMPLEMENT_SERIALIZE;
+
+ template <typename Stream, typename Operation>
+ inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
READWRITE(this->nVersion);
nVersion = this->nVersion;
READWRITE(hashPrevBlock);
@@ -421,7 +454,7 @@ public:
READWRITE(nTime);
READWRITE(nBits);
READWRITE(nNonce);
- )
+ }
void SetNull()
{
@@ -467,11 +500,13 @@ public:
*((CBlockHeader*)this) = header;
}
- IMPLEMENT_SERIALIZE
- (
+ IMPLEMENT_SERIALIZE;
+
+ template <typename Stream, typename Operation>
+ inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
READWRITE(*(CBlockHeader*)this);
READWRITE(vtx);
- )
+ }
void SetNull()
{
@@ -515,12 +550,14 @@ struct CBlockLocator
vHave = vHaveIn;
}
- 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(nVersion);
READWRITE(vHave);
- )
+ }
void SetNull()
{