Changeset View
Changeset View
Standalone View
Standalone View
src/clientversion.cpp
Show First 20 Lines • Show All 54 Lines • ▼ Show 20 Lines | static std::string FormatVersion(int nVersion) { | ||||
} | } | ||||
} | } | ||||
std::string FormatFullVersion() { | std::string FormatFullVersion() { | ||||
return CLIENT_BUILD; | return CLIENT_BUILD; | ||||
} | } | ||||
/** | /** | ||||
* Format the subversion field according to BIP 14 spec | * Format the subversion field according to BIP 14 spec using given userAgent. | ||||
* (https://github.com/bitcoin/bips/blob/master/bip-0014.mediawiki) | * (https://github.com/bitcoin/bips/blob/master/bip-0014.mediawiki) | ||||
*/ | */ | ||||
std::string FormatSubVersion(const std::string &name, int nClientVersion, | std::string | ||||
FormatSubVersionUserAgent(const std::string &userAgent, | |||||
const std::vector<std::string> &comments) { | const std::vector<std::string> &comments) { | ||||
std::ostringstream ss; | std::ostringstream ss; | ||||
ss << "/"; | ss << "/"; | ||||
ss << name << ":" << FormatVersion(nClientVersion); | ss << userAgent; | ||||
if (!comments.empty()) { | if (!comments.empty()) { | ||||
std::vector<std::string>::const_iterator it(comments.begin()); | std::vector<std::string>::const_iterator it(comments.begin()); | ||||
ss << "(" << *it; | ss << "(" << *it; | ||||
for (++it; it != comments.end(); ++it) { | for (++it; it != comments.end(); ++it) { | ||||
ss << "; " << *it; | ss << "; " << *it; | ||||
} | } | ||||
ss << ")"; | ss << ")"; | ||||
} | } | ||||
ss << "/"; | ss << "/"; | ||||
return ss.str(); | return ss.str(); | ||||
} | } | ||||
/** | |||||
* Format the subversion field according to BIP 14 spec | |||||
* (https://github.com/bitcoin/bips/blob/master/bip-0014.mediawiki) | |||||
*/ | |||||
std::string FormatSubVersion(const std::string &name, int nClientVersion, | |||||
const std::vector<std::string> &comments) { | |||||
std::ostringstream ss; | |||||
ss << name << ":" << FormatVersion(nClientVersion); | |||||
return FormatSubVersionUserAgent(ss.str(), comments); | |||||
} |