aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPieter Wuille <pieter.wuille@gmail.com>2012-04-16 14:56:45 +0200
committerPieter Wuille <pieter.wuille@gmail.com>2012-04-17 20:03:42 +0200
commit6b6aaa1698838278a547f16a15e635bd58ec867d (patch)
tree62a79e33a866c2a92f548cecb6148c7339f8beaf /src
parentccd65d426156c3d5b7a8f1123210decd1f06fe42 (diff)
Further reduce header dependencies
This commit removes the dependency of serialize.h on PROTOCOL_VERSION, and makes this parameter required instead of implicit. This is much saner, as it makes the places where changing a version number can have an influence obvious.
Diffstat (limited to 'src')
-rw-r--r--src/addrman.cpp8
-rw-r--r--src/base58.h1
-rw-r--r--src/bitcoinrpc.cpp10
-rw-r--r--src/crypter.cpp1
-rw-r--r--src/crypter.h1
-rw-r--r--src/db.cpp17
-rw-r--r--src/db.h13
-rw-r--r--src/init.cpp1
-rw-r--r--src/key.h2
-rw-r--r--src/keystore.cpp1
-rw-r--r--src/keystore.h5
-rw-r--r--src/main.cpp18
-rw-r--r--src/main.h14
-rw-r--r--src/net.h10
-rw-r--r--src/qt/bitcoin.cpp1
-rw-r--r--src/qt/messagepage.cpp2
-rw-r--r--src/qt/qtipcserver.cpp1
-rw-r--r--src/qt/walletmodel.cpp1
-rw-r--r--src/script.cpp2
-rw-r--r--src/serialize.h72
-rw-r--r--src/uint256.h11
-rw-r--r--src/util.cpp1
-rw-r--r--src/util.h1
-rw-r--r--src/wallet.cpp3
-rw-r--r--src/wallet.h1
-rw-r--r--src/walletdb.cpp8
26 files changed, 101 insertions, 105 deletions
diff --git a/src/addrman.cpp b/src/addrman.cpp
index 11dd2a7b7d..345261e229 100644
--- a/src/addrman.cpp
+++ b/src/addrman.cpp
@@ -8,12 +8,12 @@ using namespace std;
int CAddrInfo::GetTriedBucket(const std::vector<unsigned char> &nKey) const
{
- CDataStream ss1(SER_GETHASH);
+ CDataStream ss1(SER_GETHASH, 0);
std::vector<unsigned char> vchKey = GetKey();
ss1 << nKey << vchKey;
uint64 hash1 = Hash(ss1.begin(), ss1.end()).Get64();
- CDataStream ss2(SER_GETHASH);
+ CDataStream ss2(SER_GETHASH, 0);
std::vector<unsigned char> vchGroupKey = GetGroup();
ss2 << nKey << vchGroupKey << (hash1 % ADDRMAN_TRIED_BUCKETS_PER_GROUP);
uint64 hash2 = Hash(ss2.begin(), ss2.end()).Get64();
@@ -22,13 +22,13 @@ int CAddrInfo::GetTriedBucket(const std::vector<unsigned char> &nKey) const
int CAddrInfo::GetNewBucket(const std::vector<unsigned char> &nKey, const CNetAddr& src) const
{
- CDataStream ss1(SER_GETHASH);
+ CDataStream ss1(SER_GETHASH, 0);
std::vector<unsigned char> vchGroupKey = GetGroup();
std::vector<unsigned char> vchSourceGroupKey = src.GetGroup();
ss1 << nKey << vchGroupKey << vchSourceGroupKey;
uint64 hash1 = Hash(ss1.begin(), ss1.end()).Get64();
- CDataStream ss2(SER_GETHASH);
+ CDataStream ss2(SER_GETHASH, 0);
ss2 << nKey << vchSourceGroupKey << (hash1 % ADDRMAN_NEW_BUCKETS_PER_SOURCE_GROUP);
uint64 hash2 = Hash(ss2.begin(), ss2.end()).Get64();
return hash2 % ADDRMAN_NEW_BUCKET_COUNT;
diff --git a/src/base58.h b/src/base58.h
index 24b7f3ab1b..90ce34b05b 100644
--- a/src/base58.h
+++ b/src/base58.h
@@ -19,7 +19,6 @@
#include <vector>
#include "bignum.h"
#include "key.h"
-#include "util.h"
static const char* pszBase58 = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
diff --git a/src/bitcoinrpc.cpp b/src/bitcoinrpc.cpp
index e201bbe69a..b7d00c40cd 100644
--- a/src/bitcoinrpc.cpp
+++ b/src/bitcoinrpc.cpp
@@ -142,7 +142,7 @@ Object blockToJSON(const CBlock& block, const CBlockIndex* blockindex)
{
Object result;
result.push_back(Pair("hash", block.GetHash().GetHex()));
- result.push_back(Pair("size", (int)::GetSerializeSize(block, SER_NETWORK)));
+ result.push_back(Pair("size", (int)::GetSerializeSize(block, SER_NETWORK, PROTOCOL_VERSION)));
result.push_back(Pair("height", blockindex->nHeight));
result.push_back(Pair("version", block.nVersion));
result.push_back(Pair("merkleroot", block.hashMerkleRoot.GetHex()));
@@ -602,7 +602,7 @@ Value signmessage(const Array& params, bool fHelp)
if (!pwalletMain->GetKey(addr, key))
throw JSONRPCError(-4, "Private key not available");
- CDataStream ss(SER_GETHASH);
+ CDataStream ss(SER_GETHASH, 0);
ss << strMessageMagic;
ss << strMessage;
@@ -634,7 +634,7 @@ Value verifymessage(const Array& params, bool fHelp)
if (fInvalid)
throw JSONRPCError(-5, "Malformed base64 encoding");
- CDataStream ss(SER_GETHASH);
+ CDataStream ss(SER_GETHASH, 0);
ss << strMessageMagic;
ss << strMessage;
@@ -1921,7 +1921,7 @@ Value getmemorypool(const Array& params, bool fHelp)
if(tx.IsCoinBase())
continue;
- CDataStream ssTx;
+ CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION);
ssTx << tx;
transactions.push_back(HexStr(ssTx.begin(), ssTx.end()));
@@ -1943,7 +1943,7 @@ Value getmemorypool(const Array& params, bool fHelp)
else
{
// Parse parameters
- CDataStream ssBlock(ParseHex(params[0].get_str()));
+ CDataStream ssBlock(ParseHex(params[0].get_str()), SER_NETWORK, PROTOCOL_VERSION);
CBlock pblock;
ssBlock >> pblock;
diff --git a/src/crypter.cpp b/src/crypter.cpp
index 5713faf120..4f37575a6a 100644
--- a/src/crypter.cpp
+++ b/src/crypter.cpp
@@ -11,7 +11,6 @@
#endif
#include "crypter.h"
-#include "util.h"
bool CCrypter::SetKeyFromPassphrase(const SecureString& strKeyData, const std::vector<unsigned char>& chSalt, const unsigned int nRounds, const unsigned int nDerivationMethod)
{
diff --git a/src/crypter.h b/src/crypter.h
index 59a005a220..d1bdb92c91 100644
--- a/src/crypter.h
+++ b/src/crypter.h
@@ -6,6 +6,7 @@
#include "allocators.h" /* for SecureString */
#include "key.h"
+#include "serialize.h"
const unsigned int WALLET_CRYPTO_KEY_SIZE = 32;
const unsigned int WALLET_CRYPTO_SALT_SIZE = 8;
diff --git a/src/db.cpp b/src/db.cpp
index 447759f3cc..c67cf2f8a5 100644
--- a/src/db.cpp
+++ b/src/db.cpp
@@ -6,7 +6,6 @@
#include "db.h"
#include "util.h"
#include "main.h"
-#include "wallet.h"
#include <boost/version.hpp>
#include <boost/filesystem.hpp>
#include <boost/filesystem/fstream.hpp>
@@ -229,8 +228,8 @@ bool CDB::Rewrite(const string& strFile, const char* pszSkip)
if (pcursor)
while (fSuccess)
{
- CDataStream ssKey;
- CDataStream ssValue;
+ CDataStream ssKey(SER_DISK, CLIENT_VERSION);
+ CDataStream ssValue(SER_DISK, CLIENT_VERSION);
int ret = db.ReadAtCursor(pcursor, ssKey, ssValue, DB_NEXT);
if (ret == DB_NOTFOUND)
{
@@ -386,10 +385,10 @@ bool CTxDB::ReadOwnerTxes(uint160 hash160, int nMinHeight, vector<CTransaction>&
loop
{
// Read next record
- CDataStream ssKey;
+ CDataStream ssKey(SER_DISK, CLIENT_VERSION);
if (fFlags == DB_SET_RANGE)
ssKey << string("owner") << hash160 << CDiskTxPos(0, 0, 0);
- CDataStream ssValue;
+ CDataStream ssValue(SER_DISK, CLIENT_VERSION);
int ret = ReadAtCursor(pcursor, ssKey, ssValue, fFlags);
fFlags = DB_NEXT;
if (ret == DB_NOTFOUND)
@@ -514,10 +513,10 @@ bool CTxDB::LoadBlockIndex()
loop
{
// Read next record
- CDataStream ssKey;
+ CDataStream ssKey(SER_DISK, CLIENT_VERSION);
if (fFlags == DB_SET_RANGE)
ssKey << make_pair(string("blockindex"), uint256(0));
- CDataStream ssValue;
+ CDataStream ssValue(SER_DISK, CLIENT_VERSION);
int ret = ReadAtCursor(pcursor, ssKey, ssValue, fFlags);
fFlags = DB_NEXT;
if (ret == DB_NOTFOUND)
@@ -754,8 +753,8 @@ bool CAddrDB::LoadAddresses()
loop
{
// Read next record
- CDataStream ssKey;
- CDataStream ssValue;
+ CDataStream ssKey(SER_DISK, CLIENT_VERSION);
+ CDataStream ssValue(SER_DISK, CLIENT_VERSION);
int ret = ReadAtCursor(pcursor, ssKey, ssValue);
if (ret == DB_NOTFOUND)
break;
diff --git a/src/db.h b/src/db.h
index 1cd162591a..48e10a95a7 100644
--- a/src/db.h
+++ b/src/db.h
@@ -5,7 +5,6 @@
#ifndef BITCOIN_DB_H
#define BITCOIN_DB_H
-#include "key.h"
#include "main.h"
#include <map>
@@ -58,7 +57,7 @@ protected:
return false;
// Key
- CDataStream ssKey(SER_DISK);
+ CDataStream ssKey(SER_DISK, CLIENT_VERSION);
ssKey.reserve(1000);
ssKey << key;
Dbt datKey(&ssKey[0], ssKey.size());
@@ -72,7 +71,7 @@ protected:
return false;
// Unserialize value
- CDataStream ssValue((char*)datValue.get_data(), (char*)datValue.get_data() + datValue.get_size(), SER_DISK);
+ CDataStream ssValue((char*)datValue.get_data(), (char*)datValue.get_data() + datValue.get_size(), SER_DISK, CLIENT_VERSION);
ssValue >> value;
// Clear and free memory
@@ -90,13 +89,13 @@ protected:
assert(!"Write called on database in read-only mode");
// Key
- CDataStream ssKey(SER_DISK);
+ CDataStream ssKey(SER_DISK, CLIENT_VERSION);
ssKey.reserve(1000);
ssKey << key;
Dbt datKey(&ssKey[0], ssKey.size());
// Value
- CDataStream ssValue(SER_DISK);
+ CDataStream ssValue(SER_DISK, CLIENT_VERSION);
ssValue.reserve(10000);
ssValue << value;
Dbt datValue(&ssValue[0], ssValue.size());
@@ -119,7 +118,7 @@ protected:
assert(!"Erase called on database in read-only mode");
// Key
- CDataStream ssKey(SER_DISK);
+ CDataStream ssKey(SER_DISK, CLIENT_VERSION);
ssKey.reserve(1000);
ssKey << key;
Dbt datKey(&ssKey[0], ssKey.size());
@@ -139,7 +138,7 @@ protected:
return false;
// Key
- CDataStream ssKey(SER_DISK);
+ CDataStream ssKey(SER_DISK, CLIENT_VERSION);
ssKey.reserve(1000);
ssKey << key;
Dbt datKey(&ssKey[0], ssKey.size());
diff --git a/src/init.cpp b/src/init.cpp
index 886b3ab609..0eb37fe99c 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -7,7 +7,6 @@
#include "bitcoinrpc.h"
#include "net.h"
#include "init.h"
-#include "strlcpy.h"
#include "util.h"
#include "ui_interface.h"
#include <boost/filesystem.hpp>
diff --git a/src/key.h b/src/key.h
index 8f220f1c75..fc1131826d 100644
--- a/src/key.h
+++ b/src/key.h
@@ -12,7 +12,7 @@
#include <openssl/ecdsa.h>
#include <openssl/obj_mac.h>
-#include "serialize.h"
+// #include "serialize.h"
#include "uint256.h"
// secp160k1
diff --git a/src/keystore.cpp b/src/keystore.cpp
index 664f0b1242..313518711b 100644
--- a/src/keystore.cpp
+++ b/src/keystore.cpp
@@ -4,7 +4,6 @@
// file license.txt or http://www.opensource.org/licenses/mit-license.php.
#include "keystore.h"
-#include "crypter.h"
#include "script.h"
bool CKeyStore::GetPubKey(const CBitcoinAddress &address, std::vector<unsigned char> &vchPubKeyOut) const
diff --git a/src/keystore.h b/src/keystore.h
index 5d29ac1cb9..76820e204b 100644
--- a/src/keystore.h
+++ b/src/keystore.h
@@ -6,7 +6,10 @@
#define BITCOIN_KEYSTORE_H
#include "crypter.h"
-#include "script.h"
+#include "util.h"
+#include "base58.h"
+
+class CScript;
/** A virtual base class for key stores */
class CKeyStore
diff --git a/src/main.cpp b/src/main.cpp
index c2236d999f..16a1f34556 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -411,7 +411,7 @@ bool CTransaction::CheckTransaction() const
if (vout.empty())
return DoS(10, error("CTransaction::CheckTransaction() : vout empty"));
// Size limits
- if (::GetSerializeSize(*this, SER_NETWORK) > MAX_BLOCK_SIZE)
+ if (::GetSerializeSize(*this, SER_NETWORK, PROTOCOL_VERSION) > MAX_BLOCK_SIZE)
return DoS(100, error("CTransaction::CheckTransaction() : size limits failed"));
// Check for negative or overflow output values
@@ -533,7 +533,7 @@ bool CTransaction::AcceptToMemoryPool(CTxDB& txdb, bool fCheckInputs, bool* pfMi
// reasonable number of ECDSA signature verifications.
int64 nFees = GetValueIn(mapInputs)-GetValueOut();
- unsigned int nSize = ::GetSerializeSize(*this, SER_NETWORK);
+ unsigned int nSize = ::GetSerializeSize(*this, SER_NETWORK, PROTOCOL_VERSION);
// Don't accept it if it can't get into a block
if (nFees < GetMinFee(1000, true, GMF_RELAY))
@@ -1279,7 +1279,7 @@ bool CBlock::ConnectBlock(CTxDB& txdb, CBlockIndex* pindex)
bool fStrictPayToScriptHash = (pindex->nTime >= nBIP16SwitchTime);
//// issue here: it doesn't know the version
- unsigned int nTxPos = pindex->nBlockPos + ::GetSerializeSize(CBlock(), SER_DISK) - 1 + GetSizeOfCompactSize(vtx.size());
+ unsigned int nTxPos = pindex->nBlockPos + ::GetSerializeSize(CBlock(), SER_DISK, CLIENT_VERSION) - 1 + GetSizeOfCompactSize(vtx.size());
map<uint256, CTxIndex> mapQueuedChanges;
int64 nFees = 0;
@@ -1291,7 +1291,7 @@ bool CBlock::ConnectBlock(CTxDB& txdb, CBlockIndex* pindex)
return DoS(100, error("ConnectBlock() : too many sigops"));
CDiskTxPos posThisTx(pindex->nFile, pindex->nBlockPos, nTxPos);
- nTxPos += ::GetSerializeSize(tx, SER_DISK);
+ nTxPos += ::GetSerializeSize(tx, SER_DISK, CLIENT_VERSION);
MapPrevTx mapInputs;
if (!tx.IsCoinBase())
@@ -1621,7 +1621,7 @@ bool CBlock::CheckBlock() const
// that can be verified before saving an orphan block.
// Size limits
- if (vtx.empty() || vtx.size() > MAX_BLOCK_SIZE || ::GetSerializeSize(*this, SER_NETWORK) > MAX_BLOCK_SIZE)
+ if (vtx.empty() || vtx.size() > MAX_BLOCK_SIZE || ::GetSerializeSize(*this, SER_NETWORK, PROTOCOL_VERSION) > MAX_BLOCK_SIZE)
return DoS(100, error("CheckBlock() : size limits failed"));
// Check proof of work matches claimed amount
@@ -1691,7 +1691,7 @@ bool CBlock::AcceptBlock()
return DoS(100, error("AcceptBlock() : rejected by checkpoint lockin at %d", nHeight));
// Write block to history file
- if (!CheckDiskSpace(::GetSerializeSize(*this, SER_DISK)))
+ if (!CheckDiskSpace(::GetSerializeSize(*this, SER_DISK, CLIENT_VERSION)))
return error("AcceptBlock() : out of disk space");
unsigned int nFile = -1;
unsigned int nBlockPos = 0;
@@ -2481,7 +2481,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
pfrom->PushInventory(CInv(MSG_BLOCK, pindex->GetBlockHash()));
CBlock block;
block.ReadFromDisk(pindex, true);
- nBytes += block.GetSerializeSize(SER_NETWORK);
+ nBytes += block.GetSerializeSize(SER_NETWORK, PROTOCOL_VERSION);
if (--nLimit <= 0 || nBytes >= SendBufferSize()/2)
{
// When this block is requested, we'll send an inv that'll make them
@@ -3174,7 +3174,7 @@ CBlock* CreateNewBlock(CReserveKey& reservekey)
}
// Priority is sum(valuein * age) / txsize
- dPriority /= ::GetSerializeSize(tx, SER_NETWORK);
+ dPriority /= ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION);
if (porphan)
porphan->dPriority = dPriority;
@@ -3203,7 +3203,7 @@ CBlock* CreateNewBlock(CReserveKey& reservekey)
mapPriority.erase(mapPriority.begin());
// Size limits
- unsigned int nTxSize = ::GetSerializeSize(tx, SER_NETWORK);
+ unsigned int nTxSize = ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION);
if (nBlockSize + nTxSize >= MAX_BLOCK_SIZE_GEN)
continue;
diff --git a/src/main.h b/src/main.h
index b6bce014ec..bcd62080d5 100644
--- a/src/main.h
+++ b/src/main.h
@@ -7,9 +7,7 @@
#include "bignum.h"
#include "net.h"
-#include "key.h"
#include "script.h"
-#include "version.h"
#ifdef WIN32
#include <io.h> /* for _commit */
@@ -545,7 +543,7 @@ public:
// Base fee is either MIN_TX_FEE or MIN_RELAY_TX_FEE
int64 nBaseFee = (mode == GMF_RELAY) ? MIN_RELAY_TX_FEE : MIN_TX_FEE;
- unsigned int nBytes = ::GetSerializeSize(*this, SER_NETWORK);
+ unsigned int nBytes = ::GetSerializeSize(*this, SER_NETWORK, PROTOCOL_VERSION);
unsigned int nNewBlockSize = nBlockSize + nBytes;
int64 nMinFee = (1 + (int64)nBytes / 1000) * nBaseFee;
@@ -590,7 +588,7 @@ public:
bool ReadFromDisk(CDiskTxPos pos, FILE** pfileRet=NULL)
{
- CAutoFile filein = OpenBlockFile(pos.nFile, 0, pfileRet ? "rb+" : "rb");
+ CAutoFile filein = CAutoFile(OpenBlockFile(pos.nFile, 0, pfileRet ? "rb+" : "rb"), SER_DISK, CLIENT_VERSION);
if (!filein)
return error("CTransaction::ReadFromDisk() : OpenBlockFile failed");
@@ -941,7 +939,7 @@ public:
bool WriteToDisk(unsigned int& nFileRet, unsigned int& nBlockPosRet)
{
// Open history file to append
- CAutoFile fileout = AppendBlockFile(nFileRet);
+ CAutoFile fileout = CAutoFile(AppendBlockFile(nFileRet), SER_DISK, CLIENT_VERSION);
if (!fileout)
return error("CBlock::WriteToDisk() : AppendBlockFile failed");
@@ -974,7 +972,7 @@ public:
SetNull();
// Open history file to read
- CAutoFile filein = OpenBlockFile(nFile, nBlockPos, "rb");
+ CAutoFile filein = CAutoFile(OpenBlockFile(nFile, nBlockPos, "rb"), SER_DISK, CLIENT_VERSION);
if (!filein)
return error("CBlock::ReadFromDisk() : OpenBlockFile failed");
if (!fReadTransactions)
@@ -1135,7 +1133,7 @@ public:
bool EraseBlockFromDisk()
{
// Open history file
- CAutoFile fileout = OpenBlockFile(nFile, nBlockPos, "rb+");
+ CAutoFile fileout = CAutoFile(OpenBlockFile(nFile, nBlockPos, "rb+"), SER_DISK, CLIENT_VERSION);
if (!fileout)
return false;
@@ -1595,7 +1593,7 @@ public:
return error("CAlert::CheckSignature() : verify signature failed");
// Now unserialize the data
- CDataStream sMsg(vchMsg);
+ CDataStream sMsg(vchMsg, SER_NETWORK, PROTOCOL_VERSION);
sMsg >> *(CUnsignedAlert*)this;
return true;
}
diff --git a/src/net.h b/src/net.h
index 95bda9ca69..bad49a9f8f 100644
--- a/src/net.h
+++ b/src/net.h
@@ -157,14 +157,10 @@ public:
CCriticalSection cs_inventory;
std::multimap<int64, CInv> mapAskFor;
- CNode(SOCKET hSocketIn, CAddress addrIn, bool fInboundIn=false)
+ CNode(SOCKET hSocketIn, CAddress addrIn, bool fInboundIn=false) : vSend(SER_NETWORK, MIN_PROTO_VERSION), vRecv(SER_NETWORK, MIN_PROTO_VERSION)
{
nServices = 0;
hSocket = hSocketIn;
- vSend.SetType(SER_NETWORK);
- vRecv.SetType(SER_NETWORK);
- vSend.SetVersion(MIN_PROTO_VERSION);
- vRecv.SetVersion(MIN_PROTO_VERSION);
nLastSend = 0;
nLastRecv = 0;
nLastSendEmpty = GetTime();
@@ -612,7 +608,7 @@ inline void RelayInventory(const CInv& inv)
template<typename T>
void RelayMessage(const CInv& inv, const T& a)
{
- CDataStream ss(SER_NETWORK);
+ CDataStream ss(SER_NETWORK, PROTOCOL_VERSION);
ss.reserve(10000);
ss << a;
RelayMessage(inv, ss);
@@ -631,7 +627,7 @@ inline void RelayMessage<>(const CInv& inv, const CDataStream& ss)
}
// Save original serialized message so newer versions are preserved
- mapRelay[inv] = ss;
+ mapRelay.insert(std::make_pair(inv, ss));
vRelayExpiration.push_back(std::make_pair(GetTime() + 15 * 60, inv));
}
diff --git a/src/qt/bitcoin.cpp b/src/qt/bitcoin.cpp
index dfcd2af3fc..c7830871b5 100644
--- a/src/qt/bitcoin.cpp
+++ b/src/qt/bitcoin.cpp
@@ -8,6 +8,7 @@
#include "guiutil.h"
#include "init.h"
+#include "ui_interface.h"
#include "qtipcserver.h"
#include <QApplication>
diff --git a/src/qt/messagepage.cpp b/src/qt/messagepage.cpp
index 46a0cbae24..18bb64fe6c 100644
--- a/src/qt/messagepage.cpp
+++ b/src/qt/messagepage.cpp
@@ -91,7 +91,7 @@ void MessagePage::on_signMessage_clicked()
return;
}
- CDataStream ss(SER_GETHASH);
+ CDataStream ss(SER_GETHASH, 0);
ss << strMessageMagic;
ss << ui->message->document()->toPlainText().toStdString();
diff --git a/src/qt/qtipcserver.cpp b/src/qt/qtipcserver.cpp
index f7bccaaf02..102ac0ff4e 100644
--- a/src/qt/qtipcserver.cpp
+++ b/src/qt/qtipcserver.cpp
@@ -7,6 +7,7 @@
#include <boost/tokenizer.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
+#include "ui_interface.h"
#include "util.h"
#include "qtipcserver.h"
diff --git a/src/qt/walletmodel.cpp b/src/qt/walletmodel.cpp
index e23a2bb097..7a83f6cefb 100644
--- a/src/qt/walletmodel.cpp
+++ b/src/qt/walletmodel.cpp
@@ -4,6 +4,7 @@
#include "addresstablemodel.h"
#include "transactiontablemodel.h"
+#include "ui_interface.h"
#include "wallet.h"
#include "walletdb.h" // for BackupWallet
diff --git a/src/script.cpp b/src/script.cpp
index ac1f0405a8..fc0a5b3eaa 100644
--- a/src/script.cpp
+++ b/src/script.cpp
@@ -1092,7 +1092,7 @@ uint256 SignatureHash(CScript scriptCode, const CTransaction& txTo, unsigned int
}
// Serialize and hash
- CDataStream ss(SER_GETHASH);
+ CDataStream ss(SER_GETHASH, 0);
ss.reserve(10000);
ss << txTmp << nHashType;
return Hash(ss.begin(), ss.end());
diff --git a/src/serialize.h b/src/serialize.h
index 89f498e7a1..12ea1ec695 100644
--- a/src/serialize.h
+++ b/src/serialize.h
@@ -57,7 +57,7 @@ enum
};
#define IMPLEMENT_SERIALIZE(statements) \
- unsigned int GetSerializeSize(int nType=0, int nVersion=PROTOCOL_VERSION) const \
+ unsigned int GetSerializeSize(int nType, int nVersion) const \
{ \
CSerActionGetSerializeSize ser_action; \
const bool fGetSize = true; \
@@ -72,7 +72,7 @@ enum
return nSerSize; \
} \
template<typename Stream> \
- void Serialize(Stream& s, int nType=0, int nVersion=PROTOCOL_VERSION) const \
+ void Serialize(Stream& s, int nType, int nVersion) const \
{ \
CSerActionSerialize ser_action; \
const bool fGetSize = false; \
@@ -83,7 +83,7 @@ enum
{statements} \
} \
template<typename Stream> \
- void Unserialize(Stream& s, int nType=0, int nVersion=PROTOCOL_VERSION) \
+ void Unserialize(Stream& s, int nType, int nVersion) \
{ \
CSerActionUnserialize ser_action; \
const bool fGetSize = false; \
@@ -287,43 +287,43 @@ template<typename Stream, typename C> void Unserialize(Stream& is, std::basic_st
// vector
template<typename T, typename A> unsigned int GetSerializeSize_impl(const std::vector<T, A>& v, int nType, int nVersion, const boost::true_type&);
template<typename T, typename A> unsigned int GetSerializeSize_impl(const std::vector<T, A>& v, int nType, int nVersion, const boost::false_type&);
-template<typename T, typename A> inline unsigned int GetSerializeSize(const std::vector<T, A>& v, int nType, int nVersion=PROTOCOL_VERSION);
+template<typename T, typename A> inline unsigned int GetSerializeSize(const std::vector<T, A>& v, int nType, int nVersion);
template<typename Stream, typename T, typename A> void Serialize_impl(Stream& os, const std::vector<T, A>& v, int nType, int nVersion, const boost::true_type&);
template<typename Stream, typename T, typename A> void Serialize_impl(Stream& os, const std::vector<T, A>& v, int nType, int nVersion, const boost::false_type&);
-template<typename Stream, typename T, typename A> inline void Serialize(Stream& os, const std::vector<T, A>& v, int nType, int nVersion=PROTOCOL_VERSION);
+template<typename Stream, typename T, typename A> inline void Serialize(Stream& os, const std::vector<T, A>& v, int nType, int nVersion);
template<typename Stream, typename T, typename A> void Unserialize_impl(Stream& is, std::vector<T, A>& v, int nType, int nVersion, const boost::true_type&);
template<typename Stream, typename T, typename A> void Unserialize_impl(Stream& is, std::vector<T, A>& v, int nType, int nVersion, const boost::false_type&);
-template<typename Stream, typename T, typename A> inline void Unserialize(Stream& is, std::vector<T, A>& v, int nType, int nVersion=PROTOCOL_VERSION);
+template<typename Stream, typename T, typename A> inline void Unserialize(Stream& is, std::vector<T, A>& v, int nType, int nVersion);
// others derived from vector
-extern inline unsigned int GetSerializeSize(const CScript& v, int nType, int nVersion=PROTOCOL_VERSION);
-template<typename Stream> void Serialize(Stream& os, const CScript& v, int nType, int nVersion=PROTOCOL_VERSION);
-template<typename Stream> void Unserialize(Stream& is, CScript& v, int nType, int nVersion=PROTOCOL_VERSION);
+extern inline unsigned int GetSerializeSize(const CScript& v, int nType, int nVersion);
+template<typename Stream> void Serialize(Stream& os, const CScript& v, int nType, int nVersion);
+template<typename Stream> void Unserialize(Stream& is, CScript& v, int nType, int nVersion);
// pair
-template<typename K, typename T> unsigned int GetSerializeSize(const std::pair<K, T>& item, int nType, int nVersion=PROTOCOL_VERSION);
-template<typename Stream, typename K, typename T> void Serialize(Stream& os, const std::pair<K, T>& item, int nType, int nVersion=PROTOCOL_VERSION);
-template<typename Stream, typename K, typename T> void Unserialize(Stream& is, std::pair<K, T>& item, int nType, int nVersion=PROTOCOL_VERSION);
+template<typename K, typename T> unsigned int GetSerializeSize(const std::pair<K, T>& item, int nType, int nVersion);
+template<typename Stream, typename K, typename T> void Serialize(Stream& os, const std::pair<K, T>& item, int nType, int nVersion);
+template<typename Stream, typename K, typename T> void Unserialize(Stream& is, std::pair<K, T>& item, int nType, int nVersion);
// 3 tuple
-template<typename T0, typename T1, typename T2> unsigned int GetSerializeSize(const boost::tuple<T0, T1, T2>& item, int nType, int nVersion=PROTOCOL_VERSION);
-template<typename Stream, typename T0, typename T1, typename T2> void Serialize(Stream& os, const boost::tuple<T0, T1, T2>& item, int nType, int nVersion=PROTOCOL_VERSION);
-template<typename Stream, typename T0, typename T1, typename T2> void Unserialize(Stream& is, boost::tuple<T0, T1, T2>& item, int nType, int nVersion=PROTOCOL_VERSION);
+template<typename T0, typename T1, typename T2> unsigned int GetSerializeSize(const boost::tuple<T0, T1, T2>& item, int nType, int nVersion);
+template<typename Stream, typename T0, typename T1, typename T2> void Serialize(Stream& os, const boost::tuple<T0, T1, T2>& item, int nType, int nVersion);
+template<typename Stream, typename T0, typename T1, typename T2> void Unserialize(Stream& is, boost::tuple<T0, T1, T2>& item, int nType, int nVersion);
// 4 tuple
-template<typename T0, typename T1, typename T2, typename T3> unsigned int GetSerializeSize(const boost::tuple<T0, T1, T2, T3>& item, int nType, int nVersion=PROTOCOL_VERSION);
-template<typename Stream, typename T0, typename T1, typename T2, typename T3> void Serialize(Stream& os, const boost::tuple<T0, T1, T2, T3>& item, int nType, int nVersion=PROTOCOL_VERSION);
-template<typename Stream, typename T0, typename T1, typename T2, typename T3> void Unserialize(Stream& is, boost::tuple<T0, T1, T2, T3>& item, int nType, int nVersion=PROTOCOL_VERSION);
+template<typename T0, typename T1, typename T2, typename T3> unsigned int GetSerializeSize(const boost::tuple<T0, T1, T2, T3>& item, int nType, int nVersion);
+template<typename Stream, typename T0, typename T1, typename T2, typename T3> void Serialize(Stream& os, const boost::tuple<T0, T1, T2, T3>& item, int nType, int nVersion);
+template<typename Stream, typename T0, typename T1, typename T2, typename T3> void Unserialize(Stream& is, boost::tuple<T0, T1, T2, T3>& item, int nType, int nVersion);
// map
-template<typename K, typename T, typename Pred, typename A> unsigned int GetSerializeSize(const std::map<K, T, Pred, A>& m, int nType, int nVersion=PROTOCOL_VERSION);
-template<typename Stream, typename K, typename T, typename Pred, typename A> void Serialize(Stream& os, const std::map<K, T, Pred, A>& m, int nType, int nVersion=PROTOCOL_VERSION);
-template<typename Stream, typename K, typename T, typename Pred, typename A> void Unserialize(Stream& is, std::map<K, T, Pred, A>& m, int nType, int nVersion=PROTOCOL_VERSION);
+template<typename K, typename T, typename Pred, typename A> unsigned int GetSerializeSize(const std::map<K, T, Pred, A>& m, int nType, int nVersion);
+template<typename Stream, typename K, typename T, typename Pred, typename A> void Serialize(Stream& os, const std::map<K, T, Pred, A>& m, int nType, int nVersion);
+template<typename Stream, typename K, typename T, typename Pred, typename A> void Unserialize(Stream& is, std::map<K, T, Pred, A>& m, int nType, int nVersion);
// set
-template<typename K, typename Pred, typename A> unsigned int GetSerializeSize(const std::set<K, Pred, A>& m, int nType, int nVersion=PROTOCOL_VERSION);
-template<typename Stream, typename K, typename Pred, typename A> void Serialize(Stream& os, const std::set<K, Pred, A>& m, int nType, int nVersion=PROTOCOL_VERSION);
-template<typename Stream, typename K, typename Pred, typename A> void Unserialize(Stream& is, std::set<K, Pred, A>& m, int nType, int nVersion=PROTOCOL_VERSION);
+template<typename K, typename Pred, typename A> unsigned int GetSerializeSize(const std::set<K, Pred, A>& m, int nType, int nVersion);
+template<typename Stream, typename K, typename Pred, typename A> void Serialize(Stream& os, const std::set<K, Pred, A>& m, int nType, int nVersion);
+template<typename Stream, typename K, typename Pred, typename A> void Unserialize(Stream& is, std::set<K, Pred, A>& m, int nType, int nVersion);
@@ -336,19 +336,19 @@ template<typename Stream, typename K, typename Pred, typename A> void Unserializ
// Thanks to Boost serialization for this idea.
//
template<typename T>
-inline unsigned int GetSerializeSize(const T& a, long nType, int nVersion=PROTOCOL_VERSION)
+inline unsigned int GetSerializeSize(const T& a, long nType, int nVersion)
{
return a.GetSerializeSize((int)nType, nVersion);
}
template<typename Stream, typename T>
-inline void Serialize(Stream& os, const T& a, long nType, int nVersion=PROTOCOL_VERSION)
+inline void Serialize(Stream& os, const T& a, long nType, int nVersion)
{
a.Serialize(os, (int)nType, nVersion);
}
template<typename Stream, typename T>
-inline void Unserialize(Stream& is, T& a, long nType, int nVersion=PROTOCOL_VERSION)
+inline void Unserialize(Stream& is, T& a, long nType, int nVersion)
{
a.Unserialize(is, (int)nType, nVersion);
}
@@ -730,39 +730,39 @@ public:
typedef vector_type::const_iterator const_iterator;
typedef vector_type::reverse_iterator reverse_iterator;
- explicit CDataStream(int nTypeIn=SER_NETWORK, int nVersionIn=PROTOCOL_VERSION)
+ explicit CDataStream(int nTypeIn, int nVersionIn)
{
Init(nTypeIn, nVersionIn);
}
- CDataStream(const_iterator pbegin, const_iterator pend, int nTypeIn=SER_NETWORK, int nVersionIn=PROTOCOL_VERSION) : vch(pbegin, pend)
+ CDataStream(const_iterator pbegin, const_iterator pend, int nTypeIn, int nVersionIn) : vch(pbegin, pend)
{
Init(nTypeIn, nVersionIn);
}
#if !defined(_MSC_VER) || _MSC_VER >= 1300
- CDataStream(const char* pbegin, const char* pend, int nTypeIn=SER_NETWORK, int nVersionIn=PROTOCOL_VERSION) : vch(pbegin, pend)
+ CDataStream(const char* pbegin, const char* pend, int nTypeIn, int nVersionIn) : vch(pbegin, pend)
{
Init(nTypeIn, nVersionIn);
}
#endif
- CDataStream(const vector_type& vchIn, int nTypeIn=SER_NETWORK, int nVersionIn=PROTOCOL_VERSION) : vch(vchIn.begin(), vchIn.end())
+ CDataStream(const vector_type& vchIn, int nTypeIn, int nVersionIn) : vch(vchIn.begin(), vchIn.end())
{
Init(nTypeIn, nVersionIn);
}
- CDataStream(const std::vector<char>& vchIn, int nTypeIn=SER_NETWORK, int nVersionIn=PROTOCOL_VERSION) : vch(vchIn.begin(), vchIn.end())
+ CDataStream(const std::vector<char>& vchIn, int nTypeIn, int nVersionIn) : vch(vchIn.begin(), vchIn.end())
{
Init(nTypeIn, nVersionIn);
}
- CDataStream(const std::vector<unsigned char>& vchIn, int nTypeIn=SER_NETWORK, int nVersionIn=PROTOCOL_VERSION) : vch((char*)&vchIn.begin()[0], (char*)&vchIn.end()[0])
+ CDataStream(const std::vector<unsigned char>& vchIn, int nTypeIn, int nVersionIn) : vch((char*)&vchIn.begin()[0], (char*)&vchIn.end()[0])
{
Init(nTypeIn, nVersionIn);
}
- void Init(int nTypeIn=SER_NETWORK, int nVersionIn=PROTOCOL_VERSION)
+ void Init(int nTypeIn, int nVersionIn)
{
nReadPos = 0;
nType = nTypeIn;
@@ -976,7 +976,7 @@ public:
}
template<typename Stream>
- void Serialize(Stream& s, int nType=0, int nVersion=PROTOCOL_VERSION) const
+ void Serialize(Stream& s, int nType, int nVersion) const
{
// Special case: stream << stream concatenates like stream += stream
if (!vch.empty())
@@ -1085,7 +1085,7 @@ public:
typedef FILE element_type;
- CAutoFile(FILE* filenew=NULL, int nTypeIn=SER_DISK, int nVersionIn=PROTOCOL_VERSION)
+ CAutoFile(FILE* filenew, int nTypeIn, int nVersionIn)
{
file = filenew;
nType = nTypeIn;
diff --git a/src/uint256.h b/src/uint256.h
index 3524580532..bf3c55bccb 100644
--- a/src/uint256.h
+++ b/src/uint256.h
@@ -10,8 +10,6 @@
#include <string>
#include <vector>
-#include "version.h"
-
typedef long long int64;
typedef unsigned long long uint64;
@@ -355,19 +353,22 @@ public:
return pn[2*n] | (uint64)pn[2*n+1] << 32;
}
- unsigned int GetSerializeSize(int nType=0, int nVersion=PROTOCOL_VERSION) const
+// unsigned int GetSerializeSize(int nType=0, int nVersion=PROTOCOL_VERSION) const
+ unsigned int GetSerializeSize(int nType, int nVersion) const
{
return sizeof(pn);
}
template<typename Stream>
- void Serialize(Stream& s, int nType=0, int nVersion=PROTOCOL_VERSION) const
+// void Serialize(Stream& s, int nType=0, int nVersion=PROTOCOL_VERSION) const
+ void Serialize(Stream& s, int nType, int nVersion) const
{
s.write((char*)pn, sizeof(pn));
}
template<typename Stream>
- void Unserialize(Stream& s, int nType=0, int nVersion=PROTOCOL_VERSION)
+// void Unserialize(Stream& s, int nType=0, int nVersion=PROTOCOL_VERSION)
+ void Unserialize(Stream& s, int nType, int nVersion)
{
s.read((char*)pn, sizeof(pn));
}
diff --git a/src/util.cpp b/src/util.cpp
index 19005fc761..ac65d417b3 100644
--- a/src/util.cpp
+++ b/src/util.cpp
@@ -6,6 +6,7 @@
#include "util.h"
#include "strlcpy.h"
#include "version.h"
+#include "ui_interface.h"
#include <boost/algorithm/string/join.hpp>
// Work around clang compilation problem in Boost 1.46:
diff --git a/src/util.h b/src/util.h
index a4424771ce..d9ec68c620 100644
--- a/src/util.h
+++ b/src/util.h
@@ -32,7 +32,6 @@ typedef int pid_t; /* define for windows compatiblity */
#include <openssl/ripemd.h>
#include "netbase.h" // for AddTimeData
-#include "ui_interface.h"
typedef long long int64;
typedef unsigned long long uint64;
diff --git a/src/wallet.cpp b/src/wallet.cpp
index f8338b787f..53836be0cd 100644
--- a/src/wallet.cpp
+++ b/src/wallet.cpp
@@ -6,6 +6,7 @@
#include "wallet.h"
#include "walletdb.h"
#include "crypter.h"
+#include "ui_interface.h"
using namespace std;
@@ -1121,7 +1122,7 @@ bool CWallet::CreateTransaction(const vector<pair<CScript, int64> >& vecSend, CW
return false;
// Limit size
- unsigned int nBytes = ::GetSerializeSize(*(CTransaction*)&wtxNew, SER_NETWORK);
+ unsigned int nBytes = ::GetSerializeSize(*(CTransaction*)&wtxNew, SER_NETWORK, PROTOCOL_VERSION);
if (nBytes >= MAX_BLOCK_SIZE_GEN/5)
return false;
dPriority /= nBytes;
diff --git a/src/wallet.h b/src/wallet.h
index 3d9387ff82..c1461b1feb 100644
--- a/src/wallet.h
+++ b/src/wallet.h
@@ -6,7 +6,6 @@
#define BITCOIN_WALLET_H
#include "main.h"
-#include "bignum.h"
#include "key.h"
#include "keystore.h"
#include "script.h"
diff --git a/src/walletdb.cpp b/src/walletdb.cpp
index dd8069a5b1..709ecac184 100644
--- a/src/walletdb.cpp
+++ b/src/walletdb.cpp
@@ -74,10 +74,10 @@ void CWalletDB::ListAccountCreditDebit(const string& strAccount, list<CAccountin
loop
{
// Read next record
- CDataStream ssKey;
+ CDataStream ssKey(SER_DISK, CLIENT_VERSION);
if (fFlags == DB_SET_RANGE)
ssKey << boost::make_tuple(string("acentry"), (fAllAccounts? string("") : strAccount), uint64(0));
- CDataStream ssValue;
+ CDataStream ssValue(SER_DISK, CLIENT_VERSION);
int ret = ReadAtCursor(pcursor, ssKey, ssValue, fFlags);
fFlags = DB_NEXT;
if (ret == DB_NOTFOUND)
@@ -135,8 +135,8 @@ int CWalletDB::LoadWallet(CWallet* pwallet)
loop
{
// Read next record
- CDataStream ssKey;
- CDataStream ssValue;
+ CDataStream ssKey(SER_DISK, CLIENT_VERSION);
+ CDataStream ssValue(SER_DISK, CLIENT_VERSION);
int ret = ReadAtCursor(pcursor, ssKey, ssValue);
if (ret == DB_NOTFOUND)
break;