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
This commit is contained in:
s_nakamoto
2010-09-30 16:23:07 +00:00
parent 9b8eb4d690
commit a790fa46f4
22 changed files with 187 additions and 130 deletions

View File

@@ -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<typename Stream> 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<typename Stream>
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");