Use regexes to parse cluster entries.

This commit is contained in:
JoelKatz
2013-02-01 11:52:45 -08:00
parent 3d3304ff1b
commit bbc9ec1931

View File

@@ -96,22 +96,18 @@ bool UniqueNodeList::miscSave()
void UniqueNodeList::trustedLoad() void UniqueNodeList::trustedLoad()
{ {
boost::regex rNode("\\`\\s*(\\S+)[\\s]*(.*)\\'");
BOOST_FOREACH(const std::string& c, theConfig.CLUSTER_NODES) BOOST_FOREACH(const std::string& c, theConfig.CLUSTER_NODES)
{ {
std::string node, name; boost::smatch match;
size_t s = c.find(' '); if (boost::regex_match(c, match, rNode))
if (s != std::string::npos)
{ {
name = c.substr(s+1); RippleAddress a = RippleAddress::createNodePublic(match[1]);
node = c.substr(0, s); if (a.isValid())
sClusterNodes.insert(std::make_pair(a, (match.size() > 1) ? match[2] : std::string("")));
} }
else else
node = c; cLog(lsWARNING) << "Entry in cluster list invalid: '" << c << "'";
RippleAddress a = RippleAddress::createNodePublic(node);
if (a.isValid())
sClusterNodes.insert(std::make_pair(a, name));
else
cLog(lsWARNING) << "Entry in cluster list invalid: '" << node << "'";
} }
Database* db=theApp->getWalletDB()->getDB(); Database* db=theApp->getWalletDB()->getDB();