* Format the subversion field according to BIP 14 spec (https://github.com/bitcoin/bips/blob/master/bip-0014.mediawiki) */
| 85 | * Format the subversion field according to BIP 14 spec (https://github.com/bitcoin/bips/blob/master/bip-0014.mediawiki) |
| 86 | */ |
| 87 | std::string FormatSubVersion(const std::string& name, int nClientVersion, const std::vector<std::string>& comments) |
| 88 | { |
| 89 | std::ostringstream ss; |
| 90 | ss << "/"; |
| 91 | ss << name << ":" << FormatVersion(nClientVersion); |
| 92 | if (!comments.empty()) |
| 93 | { |
| 94 | std::vector<std::string>::const_iterator it(comments.begin()); |
| 95 | ss << "(" << *it; |
| 96 | for(++it; it != comments.end(); ++it) |
| 97 | ss << "; " << *it; |
| 98 | ss << ")"; |
| 99 | } |
| 100 | ss << "/"; |
| 101 | return ss.str(); |
| 102 | } |