* Format the subversion field according to BIP 14 spec (https://github.com/bitcoin/bips/blob/master/bip-0014.mediawiki) */
| 97 | * Format the subversion field according to BIP 14 spec (https://github.com/bitcoin/bips/blob/master/bip-0014.mediawiki) |
| 98 | */ |
| 99 | std::string FormatSubVersion(const std::string& name, int nClientVersion, const std::vector<std::string>& comments) |
| 100 | { |
| 101 | std::ostringstream ss; |
| 102 | ss << "/"; |
| 103 | ss << name << ":" << FormatVersion(nClientVersion); |
| 104 | if (!comments.empty()) { |
| 105 | std::vector<std::string>::const_iterator it(comments.begin()); |
| 106 | ss << "(" << *it; |
| 107 | for (++it; it != comments.end(); ++it) |
| 108 | ss << "; " << *it; |
| 109 | ss << ")"; |
| 110 | } |
| 111 | ss << "/"; |
| 112 | return ss.str(); |
| 113 | } |