From a790fa46f40d751307f86c37a709eb119768ce5b Mon Sep 17 00:00:00 2001 From: s_nakamoto Date: Thu, 30 Sep 2010 16:23:07 +0000 Subject: don't count or spend payments until they have 1 confirmation, misc cleanup, changed internal version number from 312 to 31300 -- version 0.3.13 git-svn-id: https://bitcoin.svn.sourceforge.net/svnroot/bitcoin/trunk@158 1a98c847-1fd6-4fd8-948a-caf3550aa51b --- serialize.h | 48 +++++++++++++++++++++--------------------------- 1 file changed, 21 insertions(+), 27 deletions(-) (limited to 'serialize.h') diff --git a/serialize.h b/serialize.h index 792b9096db..2eb525b978 100644 --- a/serialize.h +++ b/serialize.h @@ -22,8 +22,8 @@ class CDataStream; class CAutoFile; static const unsigned int MAX_SIZE = 0x02000000; -static const int VERSION = 312; -static const char* pszSubVer = ".8"; +static const int VERSION = 31300; +static const char* pszSubVer = ""; @@ -85,13 +85,6 @@ enum #define READWRITE(obj) (nSerSize += ::SerReadWrite(s, (obj), nType, nVersion, ser_action)) -#define READWRITEVER(obj) \ - do { \ - READWRITE((obj)); \ - if ((obj) == 10300) \ - (obj) = 300; \ - } while (false) - @@ -163,7 +156,7 @@ template inline void Unserialize(Stream& s, bool& a, int, int=0 // inline unsigned int GetSizeOfCompactSize(uint64 nSize) { - if (nSize < UCHAR_MAX-2) return sizeof(unsigned char); + if (nSize < 253) return sizeof(unsigned char); else if (nSize <= USHRT_MAX) return sizeof(unsigned char) + sizeof(unsigned short); else if (nSize <= UINT_MAX) return sizeof(unsigned char) + sizeof(unsigned int); else return sizeof(unsigned char) + sizeof(uint64); @@ -172,30 +165,31 @@ inline unsigned int GetSizeOfCompactSize(uint64 nSize) template void WriteCompactSize(Stream& os, uint64 nSize) { - if (nSize < UCHAR_MAX-2) + if (nSize < 253) { unsigned char chSize = nSize; WRITEDATA(os, chSize); } else if (nSize <= USHRT_MAX) { - unsigned char chSize = UCHAR_MAX-2; + unsigned char chSize = 253; unsigned short xSize = nSize; WRITEDATA(os, chSize); WRITEDATA(os, xSize); } else if (nSize <= UINT_MAX) { - unsigned char chSize = UCHAR_MAX-1; + unsigned char chSize = 254; unsigned int xSize = nSize; WRITEDATA(os, chSize); WRITEDATA(os, xSize); } else { - unsigned char chSize = UCHAR_MAX; + unsigned char chSize = 255; + uint64 xSize = nSize; WRITEDATA(os, chSize); - WRITEDATA(os, nSize); + WRITEDATA(os, xSize); } return; } @@ -206,27 +200,27 @@ uint64 ReadCompactSize(Stream& is) unsigned char chSize; READDATA(is, chSize); uint64 nSizeRet = 0; - if (chSize < UCHAR_MAX-2) + if (chSize < 253) { nSizeRet = chSize; } - else if (chSize == UCHAR_MAX-2) + else if (chSize == 253) { - unsigned short nSize; - READDATA(is, nSize); - nSizeRet = nSize; + unsigned short xSize; + READDATA(is, xSize); + nSizeRet = xSize; } - else if (chSize == UCHAR_MAX-1) + else if (chSize == 254) { - unsigned int nSize; - READDATA(is, nSize); - nSizeRet = nSize; + unsigned int xSize; + READDATA(is, xSize); + nSizeRet = xSize; } else { - uint64 nSize; - READDATA(is, nSize); - nSizeRet = nSize; + uint64 xSize; + READDATA(is, xSize); + nSizeRet = xSize; } if (nSizeRet > (uint64)MAX_SIZE) throw std::ios_base::failure("ReadCompactSize() : size too large"); -- cgit v1.2.3