From ba411d17a2b100a803f4ed7b7e6bf5909c270516 Mon Sep 17 00:00:00 2001 From: Simon Date: Sat, 8 Sep 2018 15:46:53 -0700 Subject: [PATCH] Fix serialization in Insight explorer code. Remove nType and nVersion from serialization Fix CScript serialization --- src/main.h | 68 ++++++++++++++++++++++++------------------------ src/spentindex.h | 4 +-- 2 files changed, 36 insertions(+), 36 deletions(-) diff --git a/src/main.h b/src/main.h index b611ccef7..36e013969 100644 --- a/src/main.h +++ b/src/main.h @@ -281,11 +281,11 @@ struct CTimestampIndexIteratorKey { return 4; } template - void Serialize(Stream& s, int nType, int nVersion) const { + void Serialize(Stream& s) const { ser_writedata32be(s, timestamp); } template - void Unserialize(Stream& s, int nType, int nVersion) { + void Unserialize(Stream& s) { timestamp = ser_readdata32be(s); } @@ -310,14 +310,14 @@ struct CTimestampIndexKey { return 36; } template - void Serialize(Stream& s, int nType, int nVersion) const { + void Serialize(Stream& s) const { ser_writedata32be(s, timestamp); - blockHash.Serialize(s, nType, nVersion); + blockHash.Serialize(s); } template - void Unserialize(Stream& s, int nType, int nVersion) { + void Unserialize(Stream& s) { timestamp = ser_readdata32be(s); - blockHash.Unserialize(s, nType, nVersion); + blockHash.Unserialize(s); } CTimestampIndexKey(unsigned int time, uint256 hash) { @@ -343,13 +343,13 @@ struct CTimestampBlockIndexKey { } template - void Serialize(Stream& s, int nType, int nVersion) const { - blockHash.Serialize(s, nType, nVersion); + void Serialize(Stream& s) const { + blockHash.Serialize(s); } template - void Unserialize(Stream& s, int nType, int nVersion) { - blockHash.Unserialize(s, nType, nVersion); + void Unserialize(Stream& s) { + blockHash.Unserialize(s); } CTimestampBlockIndexKey(uint256 hash) { @@ -372,12 +372,12 @@ struct CTimestampBlockIndexValue { } template - void Serialize(Stream& s, int nType, int nVersion) const { + void Serialize(Stream& s) const { ser_writedata32be(s, ltimestamp); } template - void Unserialize(Stream& s, int nType, int nVersion) { + void Unserialize(Stream& s) { ltimestamp = ser_readdata32be(s); } @@ -404,17 +404,17 @@ struct CAddressUnspentKey { return 57; } template - void Serialize(Stream& s, int nType, int nVersion) const { + void Serialize(Stream& s) const { ser_writedata8(s, type); - hashBytes.Serialize(s, nType, nVersion); - txhash.Serialize(s, nType, nVersion); + hashBytes.Serialize(s); + txhash.Serialize(s); ser_writedata32(s, index); } template - void Unserialize(Stream& s, int nType, int nVersion) { + void Unserialize(Stream& s) { type = ser_readdata8(s); - hashBytes.Unserialize(s, nType, nVersion); - txhash.Unserialize(s, nType, nVersion); + hashBytes.Unserialize(s); + txhash.Unserialize(s); index = ser_readdata32(s); } @@ -445,9 +445,9 @@ struct CAddressUnspentValue { ADD_SERIALIZE_METHODS; template - inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) { + inline void SerializationOp(Stream& s, Operation ser_action) { READWRITE(satoshis); - READWRITE(script); + READWRITE(*(CScriptBase*)(&script)); READWRITE(blockHeight); } @@ -485,24 +485,24 @@ struct CAddressIndexKey { return 66; } template - void Serialize(Stream& s, int nType, int nVersion) const { + void Serialize(Stream& s) const { ser_writedata8(s, type); - hashBytes.Serialize(s, nType, nVersion); + hashBytes.Serialize(s); // Heights are stored big-endian for key sorting in LevelDB ser_writedata32be(s, blockHeight); ser_writedata32be(s, txindex); - txhash.Serialize(s, nType, nVersion); + txhash.Serialize(s); ser_writedata32(s, index); char f = spending; ser_writedata8(s, f); } template - void Unserialize(Stream& s, int nType, int nVersion) { + void Unserialize(Stream& s) { type = ser_readdata8(s); - hashBytes.Unserialize(s, nType, nVersion); + hashBytes.Unserialize(s); blockHeight = ser_readdata32be(s); txindex = ser_readdata32be(s); - txhash.Unserialize(s, nType, nVersion); + txhash.Unserialize(s); index = ser_readdata32(s); char f = ser_readdata8(s); spending = f; @@ -543,14 +543,14 @@ struct CAddressIndexIteratorKey { return 21; } template - void Serialize(Stream& s, int nType, int nVersion) const { + void Serialize(Stream& s) const { ser_writedata8(s, type); - hashBytes.Serialize(s, nType, nVersion); + hashBytes.Serialize(s); } template - void Unserialize(Stream& s, int nType, int nVersion) { + void Unserialize(Stream& s) { type = ser_readdata8(s); - hashBytes.Unserialize(s, nType, nVersion); + hashBytes.Unserialize(s); } CAddressIndexIteratorKey(unsigned int addressType, uint160 addressHash) { @@ -577,15 +577,15 @@ struct CAddressIndexIteratorHeightKey { return 25; } template - void Serialize(Stream& s, int nType, int nVersion) const { + void Serialize(Stream& s) const { ser_writedata8(s, type); - hashBytes.Serialize(s, nType, nVersion); + hashBytes.Serialize(s); ser_writedata32be(s, blockHeight); } template - void Unserialize(Stream& s, int nType, int nVersion) { + void Unserialize(Stream& s) { type = ser_readdata8(s); - hashBytes.Unserialize(s, nType, nVersion); + hashBytes.Unserialize(s); blockHeight = ser_readdata32be(s); } diff --git a/src/spentindex.h b/src/spentindex.h index bd5da45d6..7b9da423b 100644 --- a/src/spentindex.h +++ b/src/spentindex.h @@ -16,7 +16,7 @@ struct CSpentIndexKey { ADD_SERIALIZE_METHODS; template - inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) { + inline void SerializationOp(Stream& s, Operation ser_action) { READWRITE(txid); READWRITE(outputIndex); } @@ -48,7 +48,7 @@ struct CSpentIndexValue { ADD_SERIALIZE_METHODS; template - inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) { + inline void SerializationOp(Stream& s, Operation ser_action) { READWRITE(txid); READWRITE(inputIndex); READWRITE(blockHeight);