mirror of
https://github.com/kvazar-network/kevacoin.git
synced 2025-02-03 02:34:14 +00:00
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.
This commit is contained in:
parent
ccd65d4261
commit
6b6aaa1698
@ -8,12 +8,12 @@ using namespace std;
|
|||||||
|
|
||||||
int CAddrInfo::GetTriedBucket(const std::vector<unsigned char> &nKey) const
|
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();
|
std::vector<unsigned char> vchKey = GetKey();
|
||||||
ss1 << nKey << vchKey;
|
ss1 << nKey << vchKey;
|
||||||
uint64 hash1 = Hash(ss1.begin(), ss1.end()).Get64();
|
uint64 hash1 = Hash(ss1.begin(), ss1.end()).Get64();
|
||||||
|
|
||||||
CDataStream ss2(SER_GETHASH);
|
CDataStream ss2(SER_GETHASH, 0);
|
||||||
std::vector<unsigned char> vchGroupKey = GetGroup();
|
std::vector<unsigned char> vchGroupKey = GetGroup();
|
||||||
ss2 << nKey << vchGroupKey << (hash1 % ADDRMAN_TRIED_BUCKETS_PER_GROUP);
|
ss2 << nKey << vchGroupKey << (hash1 % ADDRMAN_TRIED_BUCKETS_PER_GROUP);
|
||||||
uint64 hash2 = Hash(ss2.begin(), ss2.end()).Get64();
|
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
|
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> vchGroupKey = GetGroup();
|
||||||
std::vector<unsigned char> vchSourceGroupKey = src.GetGroup();
|
std::vector<unsigned char> vchSourceGroupKey = src.GetGroup();
|
||||||
ss1 << nKey << vchGroupKey << vchSourceGroupKey;
|
ss1 << nKey << vchGroupKey << vchSourceGroupKey;
|
||||||
uint64 hash1 = Hash(ss1.begin(), ss1.end()).Get64();
|
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);
|
ss2 << nKey << vchSourceGroupKey << (hash1 % ADDRMAN_NEW_BUCKETS_PER_SOURCE_GROUP);
|
||||||
uint64 hash2 = Hash(ss2.begin(), ss2.end()).Get64();
|
uint64 hash2 = Hash(ss2.begin(), ss2.end()).Get64();
|
||||||
return hash2 % ADDRMAN_NEW_BUCKET_COUNT;
|
return hash2 % ADDRMAN_NEW_BUCKET_COUNT;
|
||||||
|
@ -19,7 +19,6 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include "bignum.h"
|
#include "bignum.h"
|
||||||
#include "key.h"
|
#include "key.h"
|
||||||
#include "util.h"
|
|
||||||
|
|
||||||
static const char* pszBase58 = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
|
static const char* pszBase58 = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
|
||||||
|
|
||||||
|
@ -142,7 +142,7 @@ Object blockToJSON(const CBlock& block, const CBlockIndex* blockindex)
|
|||||||
{
|
{
|
||||||
Object result;
|
Object result;
|
||||||
result.push_back(Pair("hash", block.GetHash().GetHex()));
|
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("height", blockindex->nHeight));
|
||||||
result.push_back(Pair("version", block.nVersion));
|
result.push_back(Pair("version", block.nVersion));
|
||||||
result.push_back(Pair("merkleroot", block.hashMerkleRoot.GetHex()));
|
result.push_back(Pair("merkleroot", block.hashMerkleRoot.GetHex()));
|
||||||
@ -602,7 +602,7 @@ Value signmessage(const Array& params, bool fHelp)
|
|||||||
if (!pwalletMain->GetKey(addr, key))
|
if (!pwalletMain->GetKey(addr, key))
|
||||||
throw JSONRPCError(-4, "Private key not available");
|
throw JSONRPCError(-4, "Private key not available");
|
||||||
|
|
||||||
CDataStream ss(SER_GETHASH);
|
CDataStream ss(SER_GETHASH, 0);
|
||||||
ss << strMessageMagic;
|
ss << strMessageMagic;
|
||||||
ss << strMessage;
|
ss << strMessage;
|
||||||
|
|
||||||
@ -634,7 +634,7 @@ Value verifymessage(const Array& params, bool fHelp)
|
|||||||
if (fInvalid)
|
if (fInvalid)
|
||||||
throw JSONRPCError(-5, "Malformed base64 encoding");
|
throw JSONRPCError(-5, "Malformed base64 encoding");
|
||||||
|
|
||||||
CDataStream ss(SER_GETHASH);
|
CDataStream ss(SER_GETHASH, 0);
|
||||||
ss << strMessageMagic;
|
ss << strMessageMagic;
|
||||||
ss << strMessage;
|
ss << strMessage;
|
||||||
|
|
||||||
@ -1921,7 +1921,7 @@ Value getmemorypool(const Array& params, bool fHelp)
|
|||||||
if(tx.IsCoinBase())
|
if(tx.IsCoinBase())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
CDataStream ssTx;
|
CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION);
|
||||||
ssTx << tx;
|
ssTx << tx;
|
||||||
|
|
||||||
transactions.push_back(HexStr(ssTx.begin(), ssTx.end()));
|
transactions.push_back(HexStr(ssTx.begin(), ssTx.end()));
|
||||||
@ -1943,7 +1943,7 @@ Value getmemorypool(const Array& params, bool fHelp)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Parse parameters
|
// Parse parameters
|
||||||
CDataStream ssBlock(ParseHex(params[0].get_str()));
|
CDataStream ssBlock(ParseHex(params[0].get_str()), SER_NETWORK, PROTOCOL_VERSION);
|
||||||
CBlock pblock;
|
CBlock pblock;
|
||||||
ssBlock >> pblock;
|
ssBlock >> pblock;
|
||||||
|
|
||||||
|
@ -11,7 +11,6 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "crypter.h"
|
#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)
|
bool CCrypter::SetKeyFromPassphrase(const SecureString& strKeyData, const std::vector<unsigned char>& chSalt, const unsigned int nRounds, const unsigned int nDerivationMethod)
|
||||||
{
|
{
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
#include "allocators.h" /* for SecureString */
|
#include "allocators.h" /* for SecureString */
|
||||||
#include "key.h"
|
#include "key.h"
|
||||||
|
#include "serialize.h"
|
||||||
|
|
||||||
const unsigned int WALLET_CRYPTO_KEY_SIZE = 32;
|
const unsigned int WALLET_CRYPTO_KEY_SIZE = 32;
|
||||||
const unsigned int WALLET_CRYPTO_SALT_SIZE = 8;
|
const unsigned int WALLET_CRYPTO_SALT_SIZE = 8;
|
||||||
|
17
src/db.cpp
17
src/db.cpp
@ -6,7 +6,6 @@
|
|||||||
#include "db.h"
|
#include "db.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "wallet.h"
|
|
||||||
#include <boost/version.hpp>
|
#include <boost/version.hpp>
|
||||||
#include <boost/filesystem.hpp>
|
#include <boost/filesystem.hpp>
|
||||||
#include <boost/filesystem/fstream.hpp>
|
#include <boost/filesystem/fstream.hpp>
|
||||||
@ -229,8 +228,8 @@ bool CDB::Rewrite(const string& strFile, const char* pszSkip)
|
|||||||
if (pcursor)
|
if (pcursor)
|
||||||
while (fSuccess)
|
while (fSuccess)
|
||||||
{
|
{
|
||||||
CDataStream ssKey;
|
CDataStream ssKey(SER_DISK, CLIENT_VERSION);
|
||||||
CDataStream ssValue;
|
CDataStream ssValue(SER_DISK, CLIENT_VERSION);
|
||||||
int ret = db.ReadAtCursor(pcursor, ssKey, ssValue, DB_NEXT);
|
int ret = db.ReadAtCursor(pcursor, ssKey, ssValue, DB_NEXT);
|
||||||
if (ret == DB_NOTFOUND)
|
if (ret == DB_NOTFOUND)
|
||||||
{
|
{
|
||||||
@ -386,10 +385,10 @@ bool CTxDB::ReadOwnerTxes(uint160 hash160, int nMinHeight, vector<CTransaction>&
|
|||||||
loop
|
loop
|
||||||
{
|
{
|
||||||
// Read next record
|
// Read next record
|
||||||
CDataStream ssKey;
|
CDataStream ssKey(SER_DISK, CLIENT_VERSION);
|
||||||
if (fFlags == DB_SET_RANGE)
|
if (fFlags == DB_SET_RANGE)
|
||||||
ssKey << string("owner") << hash160 << CDiskTxPos(0, 0, 0);
|
ssKey << string("owner") << hash160 << CDiskTxPos(0, 0, 0);
|
||||||
CDataStream ssValue;
|
CDataStream ssValue(SER_DISK, CLIENT_VERSION);
|
||||||
int ret = ReadAtCursor(pcursor, ssKey, ssValue, fFlags);
|
int ret = ReadAtCursor(pcursor, ssKey, ssValue, fFlags);
|
||||||
fFlags = DB_NEXT;
|
fFlags = DB_NEXT;
|
||||||
if (ret == DB_NOTFOUND)
|
if (ret == DB_NOTFOUND)
|
||||||
@ -514,10 +513,10 @@ bool CTxDB::LoadBlockIndex()
|
|||||||
loop
|
loop
|
||||||
{
|
{
|
||||||
// Read next record
|
// Read next record
|
||||||
CDataStream ssKey;
|
CDataStream ssKey(SER_DISK, CLIENT_VERSION);
|
||||||
if (fFlags == DB_SET_RANGE)
|
if (fFlags == DB_SET_RANGE)
|
||||||
ssKey << make_pair(string("blockindex"), uint256(0));
|
ssKey << make_pair(string("blockindex"), uint256(0));
|
||||||
CDataStream ssValue;
|
CDataStream ssValue(SER_DISK, CLIENT_VERSION);
|
||||||
int ret = ReadAtCursor(pcursor, ssKey, ssValue, fFlags);
|
int ret = ReadAtCursor(pcursor, ssKey, ssValue, fFlags);
|
||||||
fFlags = DB_NEXT;
|
fFlags = DB_NEXT;
|
||||||
if (ret == DB_NOTFOUND)
|
if (ret == DB_NOTFOUND)
|
||||||
@ -754,8 +753,8 @@ bool CAddrDB::LoadAddresses()
|
|||||||
loop
|
loop
|
||||||
{
|
{
|
||||||
// Read next record
|
// Read next record
|
||||||
CDataStream ssKey;
|
CDataStream ssKey(SER_DISK, CLIENT_VERSION);
|
||||||
CDataStream ssValue;
|
CDataStream ssValue(SER_DISK, CLIENT_VERSION);
|
||||||
int ret = ReadAtCursor(pcursor, ssKey, ssValue);
|
int ret = ReadAtCursor(pcursor, ssKey, ssValue);
|
||||||
if (ret == DB_NOTFOUND)
|
if (ret == DB_NOTFOUND)
|
||||||
break;
|
break;
|
||||||
|
13
src/db.h
13
src/db.h
@ -5,7 +5,6 @@
|
|||||||
#ifndef BITCOIN_DB_H
|
#ifndef BITCOIN_DB_H
|
||||||
#define BITCOIN_DB_H
|
#define BITCOIN_DB_H
|
||||||
|
|
||||||
#include "key.h"
|
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
@ -58,7 +57,7 @@ protected:
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Key
|
// Key
|
||||||
CDataStream ssKey(SER_DISK);
|
CDataStream ssKey(SER_DISK, CLIENT_VERSION);
|
||||||
ssKey.reserve(1000);
|
ssKey.reserve(1000);
|
||||||
ssKey << key;
|
ssKey << key;
|
||||||
Dbt datKey(&ssKey[0], ssKey.size());
|
Dbt datKey(&ssKey[0], ssKey.size());
|
||||||
@ -72,7 +71,7 @@ protected:
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Unserialize value
|
// 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;
|
ssValue >> value;
|
||||||
|
|
||||||
// Clear and free memory
|
// Clear and free memory
|
||||||
@ -90,13 +89,13 @@ protected:
|
|||||||
assert(!"Write called on database in read-only mode");
|
assert(!"Write called on database in read-only mode");
|
||||||
|
|
||||||
// Key
|
// Key
|
||||||
CDataStream ssKey(SER_DISK);
|
CDataStream ssKey(SER_DISK, CLIENT_VERSION);
|
||||||
ssKey.reserve(1000);
|
ssKey.reserve(1000);
|
||||||
ssKey << key;
|
ssKey << key;
|
||||||
Dbt datKey(&ssKey[0], ssKey.size());
|
Dbt datKey(&ssKey[0], ssKey.size());
|
||||||
|
|
||||||
// Value
|
// Value
|
||||||
CDataStream ssValue(SER_DISK);
|
CDataStream ssValue(SER_DISK, CLIENT_VERSION);
|
||||||
ssValue.reserve(10000);
|
ssValue.reserve(10000);
|
||||||
ssValue << value;
|
ssValue << value;
|
||||||
Dbt datValue(&ssValue[0], ssValue.size());
|
Dbt datValue(&ssValue[0], ssValue.size());
|
||||||
@ -119,7 +118,7 @@ protected:
|
|||||||
assert(!"Erase called on database in read-only mode");
|
assert(!"Erase called on database in read-only mode");
|
||||||
|
|
||||||
// Key
|
// Key
|
||||||
CDataStream ssKey(SER_DISK);
|
CDataStream ssKey(SER_DISK, CLIENT_VERSION);
|
||||||
ssKey.reserve(1000);
|
ssKey.reserve(1000);
|
||||||
ssKey << key;
|
ssKey << key;
|
||||||
Dbt datKey(&ssKey[0], ssKey.size());
|
Dbt datKey(&ssKey[0], ssKey.size());
|
||||||
@ -139,7 +138,7 @@ protected:
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Key
|
// Key
|
||||||
CDataStream ssKey(SER_DISK);
|
CDataStream ssKey(SER_DISK, CLIENT_VERSION);
|
||||||
ssKey.reserve(1000);
|
ssKey.reserve(1000);
|
||||||
ssKey << key;
|
ssKey << key;
|
||||||
Dbt datKey(&ssKey[0], ssKey.size());
|
Dbt datKey(&ssKey[0], ssKey.size());
|
||||||
|
@ -7,7 +7,6 @@
|
|||||||
#include "bitcoinrpc.h"
|
#include "bitcoinrpc.h"
|
||||||
#include "net.h"
|
#include "net.h"
|
||||||
#include "init.h"
|
#include "init.h"
|
||||||
#include "strlcpy.h"
|
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "ui_interface.h"
|
#include "ui_interface.h"
|
||||||
#include <boost/filesystem.hpp>
|
#include <boost/filesystem.hpp>
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
#include <openssl/ecdsa.h>
|
#include <openssl/ecdsa.h>
|
||||||
#include <openssl/obj_mac.h>
|
#include <openssl/obj_mac.h>
|
||||||
|
|
||||||
#include "serialize.h"
|
// #include "serialize.h"
|
||||||
#include "uint256.h"
|
#include "uint256.h"
|
||||||
|
|
||||||
// secp160k1
|
// secp160k1
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
// file license.txt or http://www.opensource.org/licenses/mit-license.php.
|
// file license.txt or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
#include "keystore.h"
|
#include "keystore.h"
|
||||||
#include "crypter.h"
|
|
||||||
#include "script.h"
|
#include "script.h"
|
||||||
|
|
||||||
bool CKeyStore::GetPubKey(const CBitcoinAddress &address, std::vector<unsigned char> &vchPubKeyOut) const
|
bool CKeyStore::GetPubKey(const CBitcoinAddress &address, std::vector<unsigned char> &vchPubKeyOut) const
|
||||||
|
@ -6,7 +6,10 @@
|
|||||||
#define BITCOIN_KEYSTORE_H
|
#define BITCOIN_KEYSTORE_H
|
||||||
|
|
||||||
#include "crypter.h"
|
#include "crypter.h"
|
||||||
#include "script.h"
|
#include "util.h"
|
||||||
|
#include "base58.h"
|
||||||
|
|
||||||
|
class CScript;
|
||||||
|
|
||||||
/** A virtual base class for key stores */
|
/** A virtual base class for key stores */
|
||||||
class CKeyStore
|
class CKeyStore
|
||||||
|
18
src/main.cpp
18
src/main.cpp
@ -411,7 +411,7 @@ bool CTransaction::CheckTransaction() const
|
|||||||
if (vout.empty())
|
if (vout.empty())
|
||||||
return DoS(10, error("CTransaction::CheckTransaction() : vout empty"));
|
return DoS(10, error("CTransaction::CheckTransaction() : vout empty"));
|
||||||
// Size limits
|
// 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"));
|
return DoS(100, error("CTransaction::CheckTransaction() : size limits failed"));
|
||||||
|
|
||||||
// Check for negative or overflow output values
|
// 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.
|
// reasonable number of ECDSA signature verifications.
|
||||||
|
|
||||||
int64 nFees = GetValueIn(mapInputs)-GetValueOut();
|
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
|
// Don't accept it if it can't get into a block
|
||||||
if (nFees < GetMinFee(1000, true, GMF_RELAY))
|
if (nFees < GetMinFee(1000, true, GMF_RELAY))
|
||||||
@ -1279,7 +1279,7 @@ bool CBlock::ConnectBlock(CTxDB& txdb, CBlockIndex* pindex)
|
|||||||
bool fStrictPayToScriptHash = (pindex->nTime >= nBIP16SwitchTime);
|
bool fStrictPayToScriptHash = (pindex->nTime >= nBIP16SwitchTime);
|
||||||
|
|
||||||
//// issue here: it doesn't know the version
|
//// 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;
|
map<uint256, CTxIndex> mapQueuedChanges;
|
||||||
int64 nFees = 0;
|
int64 nFees = 0;
|
||||||
@ -1291,7 +1291,7 @@ bool CBlock::ConnectBlock(CTxDB& txdb, CBlockIndex* pindex)
|
|||||||
return DoS(100, error("ConnectBlock() : too many sigops"));
|
return DoS(100, error("ConnectBlock() : too many sigops"));
|
||||||
|
|
||||||
CDiskTxPos posThisTx(pindex->nFile, pindex->nBlockPos, nTxPos);
|
CDiskTxPos posThisTx(pindex->nFile, pindex->nBlockPos, nTxPos);
|
||||||
nTxPos += ::GetSerializeSize(tx, SER_DISK);
|
nTxPos += ::GetSerializeSize(tx, SER_DISK, CLIENT_VERSION);
|
||||||
|
|
||||||
MapPrevTx mapInputs;
|
MapPrevTx mapInputs;
|
||||||
if (!tx.IsCoinBase())
|
if (!tx.IsCoinBase())
|
||||||
@ -1621,7 +1621,7 @@ bool CBlock::CheckBlock() const
|
|||||||
// that can be verified before saving an orphan block.
|
// that can be verified before saving an orphan block.
|
||||||
|
|
||||||
// Size limits
|
// 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"));
|
return DoS(100, error("CheckBlock() : size limits failed"));
|
||||||
|
|
||||||
// Check proof of work matches claimed amount
|
// 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));
|
return DoS(100, error("AcceptBlock() : rejected by checkpoint lockin at %d", nHeight));
|
||||||
|
|
||||||
// Write block to history file
|
// 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");
|
return error("AcceptBlock() : out of disk space");
|
||||||
unsigned int nFile = -1;
|
unsigned int nFile = -1;
|
||||||
unsigned int nBlockPos = 0;
|
unsigned int nBlockPos = 0;
|
||||||
@ -2481,7 +2481,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
|
|||||||
pfrom->PushInventory(CInv(MSG_BLOCK, pindex->GetBlockHash()));
|
pfrom->PushInventory(CInv(MSG_BLOCK, pindex->GetBlockHash()));
|
||||||
CBlock block;
|
CBlock block;
|
||||||
block.ReadFromDisk(pindex, true);
|
block.ReadFromDisk(pindex, true);
|
||||||
nBytes += block.GetSerializeSize(SER_NETWORK);
|
nBytes += block.GetSerializeSize(SER_NETWORK, PROTOCOL_VERSION);
|
||||||
if (--nLimit <= 0 || nBytes >= SendBufferSize()/2)
|
if (--nLimit <= 0 || nBytes >= SendBufferSize()/2)
|
||||||
{
|
{
|
||||||
// When this block is requested, we'll send an inv that'll make them
|
// 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
|
// Priority is sum(valuein * age) / txsize
|
||||||
dPriority /= ::GetSerializeSize(tx, SER_NETWORK);
|
dPriority /= ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION);
|
||||||
|
|
||||||
if (porphan)
|
if (porphan)
|
||||||
porphan->dPriority = dPriority;
|
porphan->dPriority = dPriority;
|
||||||
@ -3203,7 +3203,7 @@ CBlock* CreateNewBlock(CReserveKey& reservekey)
|
|||||||
mapPriority.erase(mapPriority.begin());
|
mapPriority.erase(mapPriority.begin());
|
||||||
|
|
||||||
// Size limits
|
// 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)
|
if (nBlockSize + nTxSize >= MAX_BLOCK_SIZE_GEN)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
14
src/main.h
14
src/main.h
@ -7,9 +7,7 @@
|
|||||||
|
|
||||||
#include "bignum.h"
|
#include "bignum.h"
|
||||||
#include "net.h"
|
#include "net.h"
|
||||||
#include "key.h"
|
|
||||||
#include "script.h"
|
#include "script.h"
|
||||||
#include "version.h"
|
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
#include <io.h> /* for _commit */
|
#include <io.h> /* for _commit */
|
||||||
@ -545,7 +543,7 @@ public:
|
|||||||
// Base fee is either MIN_TX_FEE or MIN_RELAY_TX_FEE
|
// Base fee is either MIN_TX_FEE or MIN_RELAY_TX_FEE
|
||||||
int64 nBaseFee = (mode == GMF_RELAY) ? MIN_RELAY_TX_FEE : MIN_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;
|
unsigned int nNewBlockSize = nBlockSize + nBytes;
|
||||||
int64 nMinFee = (1 + (int64)nBytes / 1000) * nBaseFee;
|
int64 nMinFee = (1 + (int64)nBytes / 1000) * nBaseFee;
|
||||||
|
|
||||||
@ -590,7 +588,7 @@ public:
|
|||||||
|
|
||||||
bool ReadFromDisk(CDiskTxPos pos, FILE** pfileRet=NULL)
|
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)
|
if (!filein)
|
||||||
return error("CTransaction::ReadFromDisk() : OpenBlockFile failed");
|
return error("CTransaction::ReadFromDisk() : OpenBlockFile failed");
|
||||||
|
|
||||||
@ -941,7 +939,7 @@ public:
|
|||||||
bool WriteToDisk(unsigned int& nFileRet, unsigned int& nBlockPosRet)
|
bool WriteToDisk(unsigned int& nFileRet, unsigned int& nBlockPosRet)
|
||||||
{
|
{
|
||||||
// Open history file to append
|
// Open history file to append
|
||||||
CAutoFile fileout = AppendBlockFile(nFileRet);
|
CAutoFile fileout = CAutoFile(AppendBlockFile(nFileRet), SER_DISK, CLIENT_VERSION);
|
||||||
if (!fileout)
|
if (!fileout)
|
||||||
return error("CBlock::WriteToDisk() : AppendBlockFile failed");
|
return error("CBlock::WriteToDisk() : AppendBlockFile failed");
|
||||||
|
|
||||||
@ -974,7 +972,7 @@ public:
|
|||||||
SetNull();
|
SetNull();
|
||||||
|
|
||||||
// Open history file to read
|
// Open history file to read
|
||||||
CAutoFile filein = OpenBlockFile(nFile, nBlockPos, "rb");
|
CAutoFile filein = CAutoFile(OpenBlockFile(nFile, nBlockPos, "rb"), SER_DISK, CLIENT_VERSION);
|
||||||
if (!filein)
|
if (!filein)
|
||||||
return error("CBlock::ReadFromDisk() : OpenBlockFile failed");
|
return error("CBlock::ReadFromDisk() : OpenBlockFile failed");
|
||||||
if (!fReadTransactions)
|
if (!fReadTransactions)
|
||||||
@ -1135,7 +1133,7 @@ public:
|
|||||||
bool EraseBlockFromDisk()
|
bool EraseBlockFromDisk()
|
||||||
{
|
{
|
||||||
// Open history file
|
// Open history file
|
||||||
CAutoFile fileout = OpenBlockFile(nFile, nBlockPos, "rb+");
|
CAutoFile fileout = CAutoFile(OpenBlockFile(nFile, nBlockPos, "rb+"), SER_DISK, CLIENT_VERSION);
|
||||||
if (!fileout)
|
if (!fileout)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -1595,7 +1593,7 @@ public:
|
|||||||
return error("CAlert::CheckSignature() : verify signature failed");
|
return error("CAlert::CheckSignature() : verify signature failed");
|
||||||
|
|
||||||
// Now unserialize the data
|
// Now unserialize the data
|
||||||
CDataStream sMsg(vchMsg);
|
CDataStream sMsg(vchMsg, SER_NETWORK, PROTOCOL_VERSION);
|
||||||
sMsg >> *(CUnsignedAlert*)this;
|
sMsg >> *(CUnsignedAlert*)this;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
10
src/net.h
10
src/net.h
@ -157,14 +157,10 @@ public:
|
|||||||
CCriticalSection cs_inventory;
|
CCriticalSection cs_inventory;
|
||||||
std::multimap<int64, CInv> mapAskFor;
|
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;
|
nServices = 0;
|
||||||
hSocket = hSocketIn;
|
hSocket = hSocketIn;
|
||||||
vSend.SetType(SER_NETWORK);
|
|
||||||
vRecv.SetType(SER_NETWORK);
|
|
||||||
vSend.SetVersion(MIN_PROTO_VERSION);
|
|
||||||
vRecv.SetVersion(MIN_PROTO_VERSION);
|
|
||||||
nLastSend = 0;
|
nLastSend = 0;
|
||||||
nLastRecv = 0;
|
nLastRecv = 0;
|
||||||
nLastSendEmpty = GetTime();
|
nLastSendEmpty = GetTime();
|
||||||
@ -612,7 +608,7 @@ inline void RelayInventory(const CInv& inv)
|
|||||||
template<typename T>
|
template<typename T>
|
||||||
void RelayMessage(const CInv& inv, const T& a)
|
void RelayMessage(const CInv& inv, const T& a)
|
||||||
{
|
{
|
||||||
CDataStream ss(SER_NETWORK);
|
CDataStream ss(SER_NETWORK, PROTOCOL_VERSION);
|
||||||
ss.reserve(10000);
|
ss.reserve(10000);
|
||||||
ss << a;
|
ss << a;
|
||||||
RelayMessage(inv, ss);
|
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
|
// 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));
|
vRelayExpiration.push_back(std::make_pair(GetTime() + 15 * 60, inv));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
#include "guiutil.h"
|
#include "guiutil.h"
|
||||||
|
|
||||||
#include "init.h"
|
#include "init.h"
|
||||||
|
#include "ui_interface.h"
|
||||||
#include "qtipcserver.h"
|
#include "qtipcserver.h"
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
@ -91,7 +91,7 @@ void MessagePage::on_signMessage_clicked()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
CDataStream ss(SER_GETHASH);
|
CDataStream ss(SER_GETHASH, 0);
|
||||||
ss << strMessageMagic;
|
ss << strMessageMagic;
|
||||||
ss << ui->message->document()->toPlainText().toStdString();
|
ss << ui->message->document()->toPlainText().toStdString();
|
||||||
|
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
#include <boost/tokenizer.hpp>
|
#include <boost/tokenizer.hpp>
|
||||||
#include <boost/date_time/posix_time/posix_time.hpp>
|
#include <boost/date_time/posix_time/posix_time.hpp>
|
||||||
|
|
||||||
|
#include "ui_interface.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "qtipcserver.h"
|
#include "qtipcserver.h"
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#include "addresstablemodel.h"
|
#include "addresstablemodel.h"
|
||||||
#include "transactiontablemodel.h"
|
#include "transactiontablemodel.h"
|
||||||
|
|
||||||
|
#include "ui_interface.h"
|
||||||
#include "wallet.h"
|
#include "wallet.h"
|
||||||
#include "walletdb.h" // for BackupWallet
|
#include "walletdb.h" // for BackupWallet
|
||||||
|
|
||||||
|
@ -1092,7 +1092,7 @@ uint256 SignatureHash(CScript scriptCode, const CTransaction& txTo, unsigned int
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Serialize and hash
|
// Serialize and hash
|
||||||
CDataStream ss(SER_GETHASH);
|
CDataStream ss(SER_GETHASH, 0);
|
||||||
ss.reserve(10000);
|
ss.reserve(10000);
|
||||||
ss << txTmp << nHashType;
|
ss << txTmp << nHashType;
|
||||||
return Hash(ss.begin(), ss.end());
|
return Hash(ss.begin(), ss.end());
|
||||||
|
@ -57,7 +57,7 @@ enum
|
|||||||
};
|
};
|
||||||
|
|
||||||
#define IMPLEMENT_SERIALIZE(statements) \
|
#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; \
|
CSerActionGetSerializeSize ser_action; \
|
||||||
const bool fGetSize = true; \
|
const bool fGetSize = true; \
|
||||||
@ -72,7 +72,7 @@ enum
|
|||||||
return nSerSize; \
|
return nSerSize; \
|
||||||
} \
|
} \
|
||||||
template<typename Stream> \
|
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; \
|
CSerActionSerialize ser_action; \
|
||||||
const bool fGetSize = false; \
|
const bool fGetSize = false; \
|
||||||
@ -83,7 +83,7 @@ enum
|
|||||||
{statements} \
|
{statements} \
|
||||||
} \
|
} \
|
||||||
template<typename Stream> \
|
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; \
|
CSerActionUnserialize ser_action; \
|
||||||
const bool fGetSize = false; \
|
const bool fGetSize = false; \
|
||||||
@ -287,43 +287,43 @@ template<typename Stream, typename C> void Unserialize(Stream& is, std::basic_st
|
|||||||
// vector
|
// 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::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> 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::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> 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::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> 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
|
// others derived from vector
|
||||||
extern inline unsigned int GetSerializeSize(const 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=PROTOCOL_VERSION);
|
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=PROTOCOL_VERSION);
|
template<typename Stream> void Unserialize(Stream& is, CScript& v, int nType, int nVersion);
|
||||||
|
|
||||||
// pair
|
// pair
|
||||||
template<typename K, typename T> unsigned int GetSerializeSize(const 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=PROTOCOL_VERSION);
|
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=PROTOCOL_VERSION);
|
template<typename Stream, typename K, typename T> void Unserialize(Stream& is, std::pair<K, T>& item, int nType, int nVersion);
|
||||||
|
|
||||||
// 3 tuple
|
// 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 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=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);
|
||||||
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 Stream, typename T0, typename T1, typename T2> void Unserialize(Stream& is, boost::tuple<T0, T1, T2>& item, int nType, int nVersion);
|
||||||
|
|
||||||
// 4 tuple
|
// 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 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=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);
|
||||||
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 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
|
// 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 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=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);
|
||||||
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 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
|
// 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 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=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);
|
||||||
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 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.
|
// Thanks to Boost serialization for this idea.
|
||||||
//
|
//
|
||||||
template<typename T>
|
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);
|
return a.GetSerializeSize((int)nType, nVersion);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename Stream, typename T>
|
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);
|
a.Serialize(os, (int)nType, nVersion);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename Stream, typename T>
|
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);
|
a.Unserialize(is, (int)nType, nVersion);
|
||||||
}
|
}
|
||||||
@ -730,39 +730,39 @@ public:
|
|||||||
typedef vector_type::const_iterator const_iterator;
|
typedef vector_type::const_iterator const_iterator;
|
||||||
typedef vector_type::reverse_iterator reverse_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);
|
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);
|
Init(nTypeIn, nVersionIn);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !defined(_MSC_VER) || _MSC_VER >= 1300
|
#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);
|
Init(nTypeIn, nVersionIn);
|
||||||
}
|
}
|
||||||
#endif
|
#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);
|
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);
|
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);
|
Init(nTypeIn, nVersionIn);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Init(int nTypeIn=SER_NETWORK, int nVersionIn=PROTOCOL_VERSION)
|
void Init(int nTypeIn, int nVersionIn)
|
||||||
{
|
{
|
||||||
nReadPos = 0;
|
nReadPos = 0;
|
||||||
nType = nTypeIn;
|
nType = nTypeIn;
|
||||||
@ -976,7 +976,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<typename Stream>
|
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
|
// Special case: stream << stream concatenates like stream += stream
|
||||||
if (!vch.empty())
|
if (!vch.empty())
|
||||||
@ -1085,7 +1085,7 @@ public:
|
|||||||
|
|
||||||
typedef FILE element_type;
|
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;
|
file = filenew;
|
||||||
nType = nTypeIn;
|
nType = nTypeIn;
|
||||||
|
@ -10,8 +10,6 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "version.h"
|
|
||||||
|
|
||||||
typedef long long int64;
|
typedef long long int64;
|
||||||
typedef unsigned long long uint64;
|
typedef unsigned long long uint64;
|
||||||
|
|
||||||
@ -355,19 +353,22 @@ public:
|
|||||||
return pn[2*n] | (uint64)pn[2*n+1] << 32;
|
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);
|
return sizeof(pn);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename Stream>
|
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));
|
s.write((char*)pn, sizeof(pn));
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename Stream>
|
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));
|
s.read((char*)pn, sizeof(pn));
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "strlcpy.h"
|
#include "strlcpy.h"
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
|
#include "ui_interface.h"
|
||||||
#include <boost/algorithm/string/join.hpp>
|
#include <boost/algorithm/string/join.hpp>
|
||||||
|
|
||||||
// Work around clang compilation problem in Boost 1.46:
|
// Work around clang compilation problem in Boost 1.46:
|
||||||
|
@ -32,7 +32,6 @@ typedef int pid_t; /* define for windows compatiblity */
|
|||||||
#include <openssl/ripemd.h>
|
#include <openssl/ripemd.h>
|
||||||
|
|
||||||
#include "netbase.h" // for AddTimeData
|
#include "netbase.h" // for AddTimeData
|
||||||
#include "ui_interface.h"
|
|
||||||
|
|
||||||
typedef long long int64;
|
typedef long long int64;
|
||||||
typedef unsigned long long uint64;
|
typedef unsigned long long uint64;
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
#include "wallet.h"
|
#include "wallet.h"
|
||||||
#include "walletdb.h"
|
#include "walletdb.h"
|
||||||
#include "crypter.h"
|
#include "crypter.h"
|
||||||
|
#include "ui_interface.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
@ -1121,7 +1122,7 @@ bool CWallet::CreateTransaction(const vector<pair<CScript, int64> >& vecSend, CW
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Limit size
|
// 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)
|
if (nBytes >= MAX_BLOCK_SIZE_GEN/5)
|
||||||
return false;
|
return false;
|
||||||
dPriority /= nBytes;
|
dPriority /= nBytes;
|
||||||
|
@ -6,7 +6,6 @@
|
|||||||
#define BITCOIN_WALLET_H
|
#define BITCOIN_WALLET_H
|
||||||
|
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "bignum.h"
|
|
||||||
#include "key.h"
|
#include "key.h"
|
||||||
#include "keystore.h"
|
#include "keystore.h"
|
||||||
#include "script.h"
|
#include "script.h"
|
||||||
|
@ -74,10 +74,10 @@ void CWalletDB::ListAccountCreditDebit(const string& strAccount, list<CAccountin
|
|||||||
loop
|
loop
|
||||||
{
|
{
|
||||||
// Read next record
|
// Read next record
|
||||||
CDataStream ssKey;
|
CDataStream ssKey(SER_DISK, CLIENT_VERSION);
|
||||||
if (fFlags == DB_SET_RANGE)
|
if (fFlags == DB_SET_RANGE)
|
||||||
ssKey << boost::make_tuple(string("acentry"), (fAllAccounts? string("") : strAccount), uint64(0));
|
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);
|
int ret = ReadAtCursor(pcursor, ssKey, ssValue, fFlags);
|
||||||
fFlags = DB_NEXT;
|
fFlags = DB_NEXT;
|
||||||
if (ret == DB_NOTFOUND)
|
if (ret == DB_NOTFOUND)
|
||||||
@ -135,8 +135,8 @@ int CWalletDB::LoadWallet(CWallet* pwallet)
|
|||||||
loop
|
loop
|
||||||
{
|
{
|
||||||
// Read next record
|
// Read next record
|
||||||
CDataStream ssKey;
|
CDataStream ssKey(SER_DISK, CLIENT_VERSION);
|
||||||
CDataStream ssValue;
|
CDataStream ssValue(SER_DISK, CLIENT_VERSION);
|
||||||
int ret = ReadAtCursor(pcursor, ssKey, ssValue);
|
int ret = ReadAtCursor(pcursor, ssKey, ssValue);
|
||||||
if (ret == DB_NOTFOUND)
|
if (ret == DB_NOTFOUND)
|
||||||
break;
|
break;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user