Merge pull request #707 from gavinandresen/BIP14
Implement BIP 14 : separate protocol version from client version
This commit is contained in:
commit
1f3bc1c239
12 changed files with 96 additions and 70 deletions
|
@ -1,6 +1,6 @@
|
||||||
* update (commit) version in sources
|
* update (commit) version in sources
|
||||||
bitcoin-qt.pro
|
bitcoin-qt.pro
|
||||||
src/serialize.h
|
src/main.h (CLIENT_VERSION : PROTOCOL_VERSION in serialize.h is updated only on protocol changes)
|
||||||
share/setup.nsi
|
share/setup.nsi
|
||||||
doc/README*
|
doc/README*
|
||||||
|
|
||||||
|
|
|
@ -338,19 +338,19 @@ public:
|
||||||
return ToString(16);
|
return ToString(16);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int GetSerializeSize(int nType=0, int nVersion=VERSION) const
|
unsigned int GetSerializeSize(int nType=0, int nVersion=PROTOCOL_VERSION) const
|
||||||
{
|
{
|
||||||
return ::GetSerializeSize(getvch(), nType, nVersion);
|
return ::GetSerializeSize(getvch(), nType, nVersion);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename Stream>
|
template<typename Stream>
|
||||||
void Serialize(Stream& s, int nType=0, int nVersion=VERSION) const
|
void Serialize(Stream& s, int nType=0, int nVersion=PROTOCOL_VERSION) const
|
||||||
{
|
{
|
||||||
::Serialize(s, getvch(), nType, nVersion);
|
::Serialize(s, getvch(), nType, nVersion);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename Stream>
|
template<typename Stream>
|
||||||
void Unserialize(Stream& s, int nType=0, int nVersion=VERSION)
|
void Unserialize(Stream& s, int nType=0, int nVersion=PROTOCOL_VERSION)
|
||||||
{
|
{
|
||||||
std::vector<unsigned char> vch;
|
std::vector<unsigned char> vch;
|
||||||
::Unserialize(s, vch, nType, nVersion);
|
::Unserialize(s, vch, nType, nVersion);
|
||||||
|
|
|
@ -304,7 +304,8 @@ Value getinfo(const Array& params, bool fHelp)
|
||||||
"Returns an object containing various state info.");
|
"Returns an object containing various state info.");
|
||||||
|
|
||||||
Object obj;
|
Object obj;
|
||||||
obj.push_back(Pair("version", (int)VERSION));
|
obj.push_back(Pair("version", (int)CLIENT_VERSION));
|
||||||
|
obj.push_back(Pair("protocolversion",(int)PROTOCOL_VERSION));
|
||||||
obj.push_back(Pair("balance", ValueFromAmount(pwalletMain->GetBalance())));
|
obj.push_back(Pair("balance", ValueFromAmount(pwalletMain->GetBalance())));
|
||||||
obj.push_back(Pair("blocks", (int)nBestHeight));
|
obj.push_back(Pair("blocks", (int)nBestHeight));
|
||||||
obj.push_back(Pair("connections", (int)vNodes.size()));
|
obj.push_back(Pair("connections", (int)vNodes.size()));
|
||||||
|
|
10
src/db.cpp
10
src/db.cpp
|
@ -131,7 +131,7 @@ CDB::CDB(const char* pszFile, const char* pszMode) : pdb(NULL)
|
||||||
{
|
{
|
||||||
bool fTmp = fReadOnly;
|
bool fTmp = fReadOnly;
|
||||||
fReadOnly = false;
|
fReadOnly = false;
|
||||||
WriteVersion(VERSION);
|
WriteVersion(CLIENT_VERSION);
|
||||||
fReadOnly = fTmp;
|
fReadOnly = fTmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -236,7 +236,7 @@ bool CDB::Rewrite(const string& strFile, const char* pszSkip)
|
||||||
{
|
{
|
||||||
// Update version:
|
// Update version:
|
||||||
ssValue.clear();
|
ssValue.clear();
|
||||||
ssValue << VERSION;
|
ssValue << CLIENT_VERSION;
|
||||||
}
|
}
|
||||||
Dbt datKey(&ssKey[0], ssKey.size());
|
Dbt datKey(&ssKey[0], ssKey.size());
|
||||||
Dbt datValue(&ssValue[0], ssValue.size());
|
Dbt datValue(&ssValue[0], ssValue.size());
|
||||||
|
@ -931,7 +931,7 @@ int CWalletDB::LoadWallet(CWallet* pwallet)
|
||||||
{
|
{
|
||||||
int nMinVersion = 0;
|
int nMinVersion = 0;
|
||||||
ssValue >> nMinVersion;
|
ssValue >> nMinVersion;
|
||||||
if (nMinVersion > VERSION)
|
if (nMinVersion > CLIENT_VERSION)
|
||||||
return DB_TOO_NEW;
|
return DB_TOO_NEW;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -956,13 +956,13 @@ int CWalletDB::LoadWallet(CWallet* pwallet)
|
||||||
if (fIsEncrypted && (nFileVersion == 40000 || nFileVersion == 50000))
|
if (fIsEncrypted && (nFileVersion == 40000 || nFileVersion == 50000))
|
||||||
return DB_NEED_REWRITE;
|
return DB_NEED_REWRITE;
|
||||||
|
|
||||||
if (nFileVersion < VERSION) // Update
|
if (nFileVersion < CLIENT_VERSION) // Update
|
||||||
{
|
{
|
||||||
// Get rid of old debug.log file in current directory
|
// Get rid of old debug.log file in current directory
|
||||||
if (nFileVersion <= 105 && !pszSetDataDir[0])
|
if (nFileVersion <= 105 && !pszSetDataDir[0])
|
||||||
unlink("debug.log");
|
unlink("debug.log");
|
||||||
|
|
||||||
WriteVersion(VERSION);
|
WriteVersion(CLIENT_VERSION);
|
||||||
}
|
}
|
||||||
|
|
||||||
return DB_LOAD_OK;
|
return DB_LOAD_OK;
|
||||||
|
|
11
src/main.cpp
11
src/main.cpp
|
@ -17,6 +17,11 @@ using namespace boost;
|
||||||
// Global state
|
// Global state
|
||||||
//
|
//
|
||||||
|
|
||||||
|
// Name of client reported in the 'version' message. Report the same name
|
||||||
|
// for both bitcoind and bitcoin-qt, to make it harder for attackers to
|
||||||
|
// target servers or GUI users specifically.
|
||||||
|
const std::string CLIENT_NAME("bitcoin-qt");
|
||||||
|
|
||||||
CCriticalSection cs_setpwalletRegistered;
|
CCriticalSection cs_setpwalletRegistered;
|
||||||
set<CWallet*> setpwalletRegistered;
|
set<CWallet*> setpwalletRegistered;
|
||||||
|
|
||||||
|
@ -1847,9 +1852,9 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
|
||||||
// Change version
|
// Change version
|
||||||
if (pfrom->nVersion >= 209)
|
if (pfrom->nVersion >= 209)
|
||||||
pfrom->PushMessage("verack");
|
pfrom->PushMessage("verack");
|
||||||
pfrom->vSend.SetVersion(min(pfrom->nVersion, VERSION));
|
pfrom->vSend.SetVersion(min(pfrom->nVersion, PROTOCOL_VERSION));
|
||||||
if (pfrom->nVersion < 209)
|
if (pfrom->nVersion < 209)
|
||||||
pfrom->vRecv.SetVersion(min(pfrom->nVersion, VERSION));
|
pfrom->vRecv.SetVersion(min(pfrom->nVersion, PROTOCOL_VERSION));
|
||||||
|
|
||||||
if (!pfrom->fInbound)
|
if (!pfrom->fInbound)
|
||||||
{
|
{
|
||||||
|
@ -1902,7 +1907,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
|
||||||
|
|
||||||
else if (strCommand == "verack")
|
else if (strCommand == "verack")
|
||||||
{
|
{
|
||||||
pfrom->vRecv.SetVersion(min(pfrom->nVersion, VERSION));
|
pfrom->vRecv.SetVersion(min(pfrom->nVersion, PROTOCOL_VERSION));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,10 @@ class CRequestTracker;
|
||||||
class CNode;
|
class CNode;
|
||||||
class CBlockIndex;
|
class CBlockIndex;
|
||||||
|
|
||||||
|
static const int CLIENT_VERSION = 59900;
|
||||||
|
static const bool VERSION_IS_BETA = true;
|
||||||
|
extern const std::string CLIENT_NAME;
|
||||||
|
|
||||||
static const unsigned int MAX_BLOCK_SIZE = 1000000;
|
static const unsigned int MAX_BLOCK_SIZE = 1000000;
|
||||||
static const unsigned int MAX_BLOCK_SIZE_GEN = MAX_BLOCK_SIZE/2;
|
static const unsigned int MAX_BLOCK_SIZE_GEN = MAX_BLOCK_SIZE/2;
|
||||||
static const int MAX_BLOCK_SIGOPS = MAX_BLOCK_SIZE/50;
|
static const int MAX_BLOCK_SIGOPS = MAX_BLOCK_SIZE/50;
|
||||||
|
@ -1521,6 +1525,7 @@ public:
|
||||||
|
|
||||||
bool AppliesTo(int nVersion, std::string strSubVerIn) const
|
bool AppliesTo(int nVersion, std::string strSubVerIn) const
|
||||||
{
|
{
|
||||||
|
// TODO: rework for client-version-embedded-in-strSubVer ?
|
||||||
return (IsInEffect() &&
|
return (IsInEffect() &&
|
||||||
nMinVer <= nVersion && nVersion <= nMaxVer &&
|
nMinVer <= nVersion && nVersion <= nMaxVer &&
|
||||||
(setSubVer.empty() || setSubVer.count(strSubVerIn)));
|
(setSubVer.empty() || setSubVer.count(strSubVerIn)));
|
||||||
|
@ -1528,7 +1533,7 @@ public:
|
||||||
|
|
||||||
bool AppliesToMe() const
|
bool AppliesToMe() const
|
||||||
{
|
{
|
||||||
return AppliesTo(VERSION, ::pszSubVer);
|
return AppliesTo(PROTOCOL_VERSION, FormatSubVersion(CLIENT_NAME, CLIENT_VERSION, std::vector<std::string>()));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RelayTo(CNode* pnode) const
|
bool RelayTo(CNode* pnode) const
|
||||||
|
|
15
src/net.cpp
15
src/net.cpp
|
@ -727,6 +727,21 @@ void CNode::Cleanup()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CNode::PushVersion()
|
||||||
|
{
|
||||||
|
/// when NTP implemented, change to just nTime = GetAdjustedTime()
|
||||||
|
int64 nTime = (fInbound ? GetAdjustedTime() : GetTime());
|
||||||
|
CAddress addrYou = (fUseProxy ? CAddress("0.0.0.0") : addr);
|
||||||
|
CAddress addrMe = (fUseProxy ? CAddress("0.0.0.0") : addrLocalHost);
|
||||||
|
RAND_bytes((unsigned char*)&nLocalHostNonce, sizeof(nLocalHostNonce));
|
||||||
|
PushMessage("version", PROTOCOL_VERSION, nLocalServices, nTime, addrYou, addrMe,
|
||||||
|
nLocalHostNonce, FormatSubVersion(CLIENT_NAME, CLIENT_VERSION, std::vector<string>()), nBestHeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
std::map<unsigned int, int64> CNode::setBanned;
|
std::map<unsigned int, int64> CNode::setBanned;
|
||||||
CCriticalSection CNode::cs_setBanned;
|
CCriticalSection CNode::cs_setBanned;
|
||||||
|
|
||||||
|
|
12
src/net.h
12
src/net.h
|
@ -355,18 +355,8 @@ public:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void PushVersion()
|
|
||||||
{
|
|
||||||
/// when NTP implemented, change to just nTime = GetAdjustedTime()
|
|
||||||
int64 nTime = (fInbound ? GetAdjustedTime() : GetTime());
|
|
||||||
CAddress addrYou = (fUseProxy ? CAddress("0.0.0.0") : addr);
|
|
||||||
CAddress addrMe = (fUseProxy ? CAddress("0.0.0.0") : addrLocalHost);
|
|
||||||
RAND_bytes((unsigned char*)&nLocalHostNonce, sizeof(nLocalHostNonce));
|
|
||||||
PushMessage("version", VERSION, nLocalServices, nTime, addrYou, addrMe,
|
|
||||||
nLocalHostNonce, std::string(pszSubVer), nBestHeight);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
void PushVersion();
|
||||||
|
|
||||||
|
|
||||||
void PushMessage(const char* pszCommand)
|
void PushMessage(const char* pszCommand)
|
||||||
|
|
|
@ -60,9 +60,7 @@ class CDataStream;
|
||||||
class CAutoFile;
|
class CAutoFile;
|
||||||
static const unsigned int MAX_SIZE = 0x02000000;
|
static const unsigned int MAX_SIZE = 0x02000000;
|
||||||
|
|
||||||
static const int VERSION = 59900;
|
static const int PROTOCOL_VERSION = 60000;
|
||||||
static const char* pszSubVer = "";
|
|
||||||
static const bool VERSION_IS_BETA = true;
|
|
||||||
|
|
||||||
// Used to bypass the rule against non-const reference to temporary
|
// Used to bypass the rule against non-const reference to temporary
|
||||||
// where it makes sense with wrappers such as CFlatData or CTxDB
|
// where it makes sense with wrappers such as CFlatData or CTxDB
|
||||||
|
@ -91,7 +89,7 @@ enum
|
||||||
};
|
};
|
||||||
|
|
||||||
#define IMPLEMENT_SERIALIZE(statements) \
|
#define IMPLEMENT_SERIALIZE(statements) \
|
||||||
unsigned int GetSerializeSize(int nType=0, int nVersion=VERSION) const \
|
unsigned int GetSerializeSize(int nType=0, int nVersion=PROTOCOL_VERSION) const \
|
||||||
{ \
|
{ \
|
||||||
CSerActionGetSerializeSize ser_action; \
|
CSerActionGetSerializeSize ser_action; \
|
||||||
const bool fGetSize = true; \
|
const bool fGetSize = true; \
|
||||||
|
@ -105,7 +103,7 @@ enum
|
||||||
return nSerSize; \
|
return nSerSize; \
|
||||||
} \
|
} \
|
||||||
template<typename Stream> \
|
template<typename Stream> \
|
||||||
void Serialize(Stream& s, int nType=0, int nVersion=VERSION) const \
|
void Serialize(Stream& s, int nType=0, int nVersion=PROTOCOL_VERSION) const \
|
||||||
{ \
|
{ \
|
||||||
CSerActionSerialize ser_action; \
|
CSerActionSerialize ser_action; \
|
||||||
const bool fGetSize = false; \
|
const bool fGetSize = false; \
|
||||||
|
@ -115,7 +113,7 @@ enum
|
||||||
{statements} \
|
{statements} \
|
||||||
} \
|
} \
|
||||||
template<typename Stream> \
|
template<typename Stream> \
|
||||||
void Unserialize(Stream& s, int nType=0, int nVersion=VERSION) \
|
void Unserialize(Stream& s, int nType=0, int nVersion=PROTOCOL_VERSION) \
|
||||||
{ \
|
{ \
|
||||||
CSerActionUnserialize ser_action; \
|
CSerActionUnserialize ser_action; \
|
||||||
const bool fGetSize = false; \
|
const bool fGetSize = false; \
|
||||||
|
@ -362,43 +360,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=VERSION);
|
template<typename T, typename A> inline unsigned int GetSerializeSize(const std::vector<T, A>& v, int nType, int nVersion=PROTOCOL_VERSION);
|
||||||
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=VERSION);
|
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> 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=VERSION);
|
template<typename Stream, typename T, typename A> inline void Unserialize(Stream& is, std::vector<T, A>& v, int nType, int nVersion=PROTOCOL_VERSION);
|
||||||
|
|
||||||
// others derived from vector
|
// others derived from vector
|
||||||
extern inline unsigned int GetSerializeSize(const CScript& v, int nType, int nVersion=VERSION);
|
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=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=VERSION);
|
template<typename Stream> void Unserialize(Stream& is, CScript& v, int nType, int nVersion=PROTOCOL_VERSION);
|
||||||
|
|
||||||
// pair
|
// pair
|
||||||
template<typename K, typename T> unsigned int GetSerializeSize(const std::pair<K, T>& item, int nType, int nVersion=VERSION);
|
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=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=VERSION);
|
template<typename Stream, typename K, typename T> void Unserialize(Stream& is, std::pair<K, T>& item, int nType, int nVersion=PROTOCOL_VERSION);
|
||||||
|
|
||||||
// 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=VERSION);
|
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=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=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);
|
||||||
|
|
||||||
// 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=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=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=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=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);
|
||||||
|
|
||||||
// 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=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=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=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=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);
|
||||||
|
|
||||||
// set
|
// set
|
||||||
template<typename K, typename Pred, typename A> unsigned int GetSerializeSize(const std::set<K, Pred, A>& m, int nType, int nVersion=VERSION);
|
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=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=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);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -411,19 +409,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=VERSION)
|
inline unsigned int GetSerializeSize(const T& a, long nType, int nVersion=PROTOCOL_VERSION)
|
||||||
{
|
{
|
||||||
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=VERSION)
|
inline void Serialize(Stream& os, const T& a, long nType, int nVersion=PROTOCOL_VERSION)
|
||||||
{
|
{
|
||||||
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=VERSION)
|
inline void Unserialize(Stream& is, T& a, long nType, int nVersion=PROTOCOL_VERSION)
|
||||||
{
|
{
|
||||||
a.Unserialize(is, (int)nType, nVersion);
|
a.Unserialize(is, (int)nType, nVersion);
|
||||||
}
|
}
|
||||||
|
@ -857,39 +855,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=VERSION)
|
explicit CDataStream(int nTypeIn=SER_NETWORK, int nVersionIn=PROTOCOL_VERSION)
|
||||||
{
|
{
|
||||||
Init(nTypeIn, nVersionIn);
|
Init(nTypeIn, nVersionIn);
|
||||||
}
|
}
|
||||||
|
|
||||||
CDataStream(const_iterator pbegin, const_iterator pend, int nTypeIn=SER_NETWORK, int nVersionIn=VERSION) : vch(pbegin, pend)
|
CDataStream(const_iterator pbegin, const_iterator pend, int nTypeIn=SER_NETWORK, int nVersionIn=PROTOCOL_VERSION) : 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=VERSION) : vch(pbegin, pend)
|
CDataStream(const char* pbegin, const char* pend, int nTypeIn=SER_NETWORK, int nVersionIn=PROTOCOL_VERSION) : vch(pbegin, pend)
|
||||||
{
|
{
|
||||||
Init(nTypeIn, nVersionIn);
|
Init(nTypeIn, nVersionIn);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
CDataStream(const vector_type& vchIn, int nTypeIn=SER_NETWORK, int nVersionIn=VERSION) : vch(vchIn.begin(), vchIn.end())
|
CDataStream(const vector_type& vchIn, int nTypeIn=SER_NETWORK, int nVersionIn=PROTOCOL_VERSION) : vch(vchIn.begin(), vchIn.end())
|
||||||
{
|
{
|
||||||
Init(nTypeIn, nVersionIn);
|
Init(nTypeIn, nVersionIn);
|
||||||
}
|
}
|
||||||
|
|
||||||
CDataStream(const std::vector<char>& vchIn, int nTypeIn=SER_NETWORK, int nVersionIn=VERSION) : vch(vchIn.begin(), vchIn.end())
|
CDataStream(const std::vector<char>& vchIn, int nTypeIn=SER_NETWORK, int nVersionIn=PROTOCOL_VERSION) : vch(vchIn.begin(), vchIn.end())
|
||||||
{
|
{
|
||||||
Init(nTypeIn, nVersionIn);
|
Init(nTypeIn, nVersionIn);
|
||||||
}
|
}
|
||||||
|
|
||||||
CDataStream(const std::vector<unsigned char>& vchIn, int nTypeIn=SER_NETWORK, int nVersionIn=VERSION) : vch((char*)&vchIn.begin()[0], (char*)&vchIn.end()[0])
|
CDataStream(const std::vector<unsigned char>& vchIn, int nTypeIn=SER_NETWORK, int nVersionIn=PROTOCOL_VERSION) : vch((char*)&vchIn.begin()[0], (char*)&vchIn.end()[0])
|
||||||
{
|
{
|
||||||
Init(nTypeIn, nVersionIn);
|
Init(nTypeIn, nVersionIn);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Init(int nTypeIn=SER_NETWORK, int nVersionIn=VERSION)
|
void Init(int nTypeIn=SER_NETWORK, int nVersionIn=PROTOCOL_VERSION)
|
||||||
{
|
{
|
||||||
nReadPos = 0;
|
nReadPos = 0;
|
||||||
nType = nTypeIn;
|
nType = nTypeIn;
|
||||||
|
@ -1103,7 +1101,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename Stream>
|
template<typename Stream>
|
||||||
void Serialize(Stream& s, int nType=0, int nVersion=VERSION) const
|
void Serialize(Stream& s, int nType=0, int nVersion=PROTOCOL_VERSION) const
|
||||||
{
|
{
|
||||||
// Special case: stream << stream concatenates like stream += stream
|
// Special case: stream << stream concatenates like stream += stream
|
||||||
if (!vch.empty())
|
if (!vch.empty())
|
||||||
|
@ -1212,7 +1210,7 @@ public:
|
||||||
|
|
||||||
typedef FILE element_type;
|
typedef FILE element_type;
|
||||||
|
|
||||||
CAutoFile(FILE* filenew=NULL, int nTypeIn=SER_DISK, int nVersionIn=VERSION)
|
CAutoFile(FILE* filenew=NULL, int nTypeIn=SER_DISK, int nVersionIn=PROTOCOL_VERSION)
|
||||||
{
|
{
|
||||||
file = filenew;
|
file = filenew;
|
||||||
nType = nTypeIn;
|
nType = nTypeIn;
|
||||||
|
|
|
@ -364,19 +364,19 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
unsigned int GetSerializeSize(int nType=0, int nVersion=VERSION) const
|
unsigned int GetSerializeSize(int nType=0, int nVersion=PROTOCOL_VERSION) const
|
||||||
{
|
{
|
||||||
return sizeof(pn);
|
return sizeof(pn);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename Stream>
|
template<typename Stream>
|
||||||
void Serialize(Stream& s, int nType=0, int nVersion=VERSION) const
|
void Serialize(Stream& s, int nType=0, int nVersion=PROTOCOL_VERSION) 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=VERSION)
|
void Unserialize(Stream& s, int nType=0, int nVersion=PROTOCOL_VERSION)
|
||||||
{
|
{
|
||||||
s.read((char*)pn, sizeof(pn));
|
s.read((char*)pn, sizeof(pn));
|
||||||
}
|
}
|
||||||
|
|
14
src/util.cpp
14
src/util.cpp
|
@ -4,6 +4,7 @@
|
||||||
// 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 "headers.h"
|
#include "headers.h"
|
||||||
#include "strlcpy.h"
|
#include "strlcpy.h"
|
||||||
|
#include <boost/algorithm/string/join.hpp>
|
||||||
#include <boost/program_options/detail/config_file.hpp>
|
#include <boost/program_options/detail/config_file.hpp>
|
||||||
#include <boost/program_options/parsers.hpp>
|
#include <boost/program_options/parsers.hpp>
|
||||||
#include <boost/filesystem.hpp>
|
#include <boost/filesystem.hpp>
|
||||||
|
@ -1001,7 +1002,7 @@ string FormatVersion(int nVersion)
|
||||||
|
|
||||||
string FormatFullVersion()
|
string FormatFullVersion()
|
||||||
{
|
{
|
||||||
string s = FormatVersion(VERSION) + pszSubVer;
|
string s = FormatVersion(CLIENT_VERSION);
|
||||||
if (VERSION_IS_BETA) {
|
if (VERSION_IS_BETA) {
|
||||||
s += "-";
|
s += "-";
|
||||||
s += _("beta");
|
s += _("beta");
|
||||||
|
@ -1009,6 +1010,17 @@ string FormatFullVersion()
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Format the subversion field according to BIP 14 spec (https://en.bitcoin.it/wiki/BIP_0014)
|
||||||
|
std::string FormatSubVersion(const std::string& name, int nClientVersion, const std::vector<std::string>& comments)
|
||||||
|
{
|
||||||
|
std::ostringstream ss;
|
||||||
|
ss << "/";
|
||||||
|
ss << name << ":" << FormatVersion(nClientVersion);
|
||||||
|
if (!comments.empty())
|
||||||
|
ss << "(" << boost::algorithm::join(comments, "; ") << ")";
|
||||||
|
ss << "/";
|
||||||
|
return ss.str();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -204,7 +204,7 @@ void SetMockTime(int64 nMockTimeIn);
|
||||||
int64 GetAdjustedTime();
|
int64 GetAdjustedTime();
|
||||||
void AddTimeData(unsigned int ip, int64 nTime);
|
void AddTimeData(unsigned int ip, int64 nTime);
|
||||||
std::string FormatFullVersion();
|
std::string FormatFullVersion();
|
||||||
|
std::string FormatSubVersion(const std::string& name, int nClientVersion, const std::vector<std::string>& comments);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -558,7 +558,7 @@ inline uint256 Hash(const T1 p1begin, const T1 p1end,
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
uint256 SerializeHash(const T& obj, int nType=SER_GETHASH, int nVersion=VERSION)
|
uint256 SerializeHash(const T& obj, int nType=SER_GETHASH, int nVersion=PROTOCOL_VERSION)
|
||||||
{
|
{
|
||||||
// Most of the time is spent allocating and deallocating CDataStream's
|
// Most of the time is spent allocating and deallocating CDataStream's
|
||||||
// buffer. If this ever needs to be optimized further, make a CStaticStream
|
// buffer. If this ever needs to be optimized further, make a CStaticStream
|
||||||
|
|
Loading…
Reference in a new issue