Get rid of nType and nVersion

Remove the nType and nVersion as parameters to all serialization methods
and functions. There is only one place where it's read and has an impact
(in CAddress), and even there it does not impact any of the recursively
invoked serializers.

Instead, the few places that need nType or nVersion are changed to read
it directly from the stream object, through GetType() and GetVersion()
methods which are added to all stream classes.
This commit is contained in:
Pieter Wuille
2016-10-28 16:29:17 -07:00
parent 657e05ab2e
commit 528472111b
36 changed files with 304 additions and 280 deletions

View File

@@ -17,7 +17,7 @@ using namespace std;
class CAddrManSerializationMock : public CAddrMan
{
public:
virtual void Serialize(CDataStream& s, int nType, int nVersionDummy) const = 0;
virtual void Serialize(CDataStream& s) const = 0;
//! Ensure that bucket placement is always the same for testing purposes.
void MakeDeterministic()
@@ -30,16 +30,16 @@ public:
class CAddrManUncorrupted : public CAddrManSerializationMock
{
public:
void Serialize(CDataStream& s, int nType, int nVersionDummy) const
void Serialize(CDataStream& s) const
{
CAddrMan::Serialize(s, nType, nVersionDummy);
CAddrMan::Serialize(s);
}
};
class CAddrManCorrupted : public CAddrManSerializationMock
{
public:
void Serialize(CDataStream& s, int nType, int nVersionDummy) const
void Serialize(CDataStream& s) const
{
// Produces corrupt output that claims addrman has 20 addrs when it only has one addr.
unsigned char nVersion = 1;