Rename to Section

This commit is contained in:
Vinnie Falco
2013-06-20 14:30:52 -07:00
parent 03087d10b1
commit 2398df7235
6 changed files with 131 additions and 129 deletions

View File

@@ -1840,6 +1840,7 @@
<ClInclude Include="..\..\Subtrees\leveldb\util\random.h" /> <ClInclude Include="..\..\Subtrees\leveldb\util\random.h" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="..\..\CheatSheet.md" />
<None Include="..\..\CodingStyle.md" /> <None Include="..\..\CodingStyle.md" />
<None Include="..\..\Doxyfile" /> <None Include="..\..\Doxyfile" />
<None Include="..\..\modules\ripple_json\json\json_internalarray.inl" /> <None Include="..\..\modules\ripple_json\json\json_internalarray.inl" />

View File

@@ -1668,6 +1668,7 @@
<None Include="..\..\Doxyfile" /> <None Include="..\..\Doxyfile" />
<None Include="..\..\README.md" /> <None Include="..\..\README.md" />
<None Include="..\..\SConstruct" /> <None Include="..\..\SConstruct" />
<None Include="..\..\CheatSheet.md" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<CustomBuild Include="..\..\src\cpp\ripple\ripple.proto" /> <CustomBuild Include="..\..\src\cpp\ripple\ripple.proto" />

View File

@@ -11,11 +11,11 @@ struct ParseSectionLog { };
SETUP_LOG (ParseSectionLog) SETUP_LOG (ParseSectionLog)
section ParseSection (const std::string& strInput, const bool bTrim) Section ParseSection (const std::string& strInput, const bool bTrim)
{ {
std::string strData (strInput); std::string strData (strInput);
std::vector<std::string> vLines; std::vector<std::string> vLines;
section secResult; Section secResult;
// Convert DOS format to unix. // Convert DOS format to unix.
boost::algorithm::replace_all (strData, "\r\n", "\n"); boost::algorithm::replace_all (strData, "\r\n", "\n");
@@ -25,11 +25,11 @@ section ParseSection (const std::string& strInput, const bool bTrim)
boost::algorithm::split (vLines, strData, boost::algorithm::is_any_of ("\n")); boost::algorithm::split (vLines, strData, boost::algorithm::is_any_of ("\n"));
// Set the default section name. // Set the default Section name.
std::string strSection = SECTION_DEFAULT_NAME; std::string strSection = SECTION_DEFAULT_NAME;
// Initialize the default section. // Initialize the default Section.
secResult[strSection] = section::mapped_type (); secResult[strSection] = Section::mapped_type ();
// Parse each line. // Parse each line.
BOOST_FOREACH (std::string & strValue, vLines) BOOST_FOREACH (std::string & strValue, vLines)
@@ -42,14 +42,14 @@ section ParseSection (const std::string& strInput, const bool bTrim)
} }
else if (strValue[0] == '[' && strValue[strValue.length () - 1] == ']') else if (strValue[0] == '[' && strValue[strValue.length () - 1] == ']')
{ {
// New section. // New Section.
strSection = strValue.substr (1, strValue.length () - 2); strSection = strValue.substr (1, strValue.length () - 2);
secResult[strSection] = section::mapped_type (); secResult[strSection] = Section::mapped_type ();
} }
else else
{ {
// Another line for section. // Another line for Section.
if (bTrim) if (bTrim)
boost::algorithm::trim (strValue); boost::algorithm::trim (strValue);
@@ -61,7 +61,7 @@ section ParseSection (const std::string& strInput, const bool bTrim)
return secResult; return secResult;
} }
void sectionEntriesPrint (std::vector<std::string>* vspEntries, const std::string& strSection) void SectionEntriesPrint (std::vector<std::string>* vspEntries, const std::string& strSection)
{ {
std::cerr << "[" << strSection << "]" << std::endl; std::cerr << "[" << strSection << "]" << std::endl;
@@ -74,18 +74,18 @@ void sectionEntriesPrint (std::vector<std::string>* vspEntries, const std::strin
} }
} }
void sectionPrint (section secInput) void SectionPrint (Section secInput)
{ {
BOOST_FOREACH (section::value_type & pairSection, secInput) BOOST_FOREACH (Section::value_type & pairSection, secInput)
{ {
sectionEntriesPrint (&pairSection.second, pairSection.first); SectionEntriesPrint (&pairSection.second, pairSection.first);
} }
} }
section::mapped_type* sectionEntries (section& secSource, const std::string& strSection) Section::mapped_type* SectionEntries (Section& secSource, const std::string& strSection)
{ {
section::iterator it; Section::iterator it;
section::mapped_type* smtResult; Section::mapped_type* smtResult;
it = secSource.find (strSection); it = secSource.find (strSection);
@@ -95,7 +95,7 @@ section::mapped_type* sectionEntries (section& secSource, const std::string& str
} }
else else
{ {
//section::mapped_type& vecEntries = it->second; //Section::mapped_type& vecEntries = it->second;
smtResult = & (it->second); smtResult = & (it->second);
} }
@@ -103,16 +103,16 @@ section::mapped_type* sectionEntries (section& secSource, const std::string& str
return smtResult; return smtResult;
} }
int sectionCount (section& secSource, const std::string& strSection) int SectionCount (Section& secSource, const std::string& strSection)
{ {
section::mapped_type* pmtEntries = sectionEntries (secSource, strSection); Section::mapped_type* pmtEntries = SectionEntries (secSource, strSection);
return pmtEntries ? -1 : pmtEntries->size (); return pmtEntries ? -1 : pmtEntries->size ();
} }
bool sectionSingleB (section& secSource, const std::string& strSection, std::string& strValue) bool SectionSingleB (Section& secSource, const std::string& strSection, std::string& strValue)
{ {
section::mapped_type* pmtEntries = sectionEntries (secSource, strSection); Section::mapped_type* pmtEntries = SectionEntries (secSource, strSection);
bool bSingle = pmtEntries && 1 == pmtEntries->size (); bool bSingle = pmtEntries && 1 == pmtEntries->size ();
if (bSingle) if (bSingle)

View File

@@ -7,13 +7,13 @@
#ifndef _PARSE_SECTION_ #ifndef _PARSE_SECTION_
#define _PARSE_SECTION_ #define _PARSE_SECTION_
typedef std::map<const std::string, std::vector<std::string> > section; typedef std::map<const std::string, std::vector<std::string> > Section;
section ParseSection (const std::string& strInput, const bool bTrim); Section ParseSection (const std::string& strInput, const bool bTrim);
void sectionPrint (section secInput); void SectionPrint (Section secInput);
void sectionEntriesPrint (std::vector<std::string>* vspEntries, const std::string& strSection); void SectionEntriesPrint (std::vector<std::string>* vspEntries, const std::string& strSection);
bool sectionSingleB (section& secSource, const std::string& strSection, std::string& strValue); bool SectionSingleB (Section& secSource, const std::string& strSection, std::string& strValue);
int sectionCount (section& secSource, const std::string& strSection); int SectionCount (Section& secSource, const std::string& strSection);
section::mapped_type* sectionEntries (section& secSource, const std::string& strSection); Section::mapped_type* SectionEntries (Section& secSource, const std::string& strSection);
#endif #endif

View File

@@ -295,44 +295,44 @@ void Config::load ()
} }
else else
{ {
section secConfig = ParseSection (strConfigFile, true); Section secConfig = ParseSection (strConfigFile, true);
std::string strTemp; std::string strTemp;
// XXX Leak // XXX Leak
section::mapped_type* smtTmp; Section::mapped_type* smtTmp;
smtTmp = sectionEntries (secConfig, SECTION_VALIDATORS); smtTmp = SectionEntries (secConfig, SECTION_VALIDATORS);
if (smtTmp) if (smtTmp)
{ {
VALIDATORS = *smtTmp; VALIDATORS = *smtTmp;
// sectionEntriesPrint(&VALIDATORS, SECTION_VALIDATORS); // SectionEntriesPrint(&VALIDATORS, SECTION_VALIDATORS);
} }
smtTmp = sectionEntries (secConfig, SECTION_CLUSTER_NODES); smtTmp = SectionEntries (secConfig, SECTION_CLUSTER_NODES);
if (smtTmp) if (smtTmp)
{ {
CLUSTER_NODES = *smtTmp; CLUSTER_NODES = *smtTmp;
// sectionEntriesPrint(&CLUSTER_NODES, SECTION_CLUSTER_NODES); // SectionEntriesPrint(&CLUSTER_NODES, SECTION_CLUSTER_NODES);
} }
smtTmp = sectionEntries (secConfig, SECTION_IPS); smtTmp = SectionEntries (secConfig, SECTION_IPS);
if (smtTmp) if (smtTmp)
{ {
IPS = *smtTmp; IPS = *smtTmp;
// sectionEntriesPrint(&IPS, SECTION_IPS); // SectionEntriesPrint(&IPS, SECTION_IPS);
} }
smtTmp = sectionEntries (secConfig, SECTION_SNTP); smtTmp = SectionEntries (secConfig, SECTION_SNTP);
if (smtTmp) if (smtTmp)
{ {
SNTP_SERVERS = *smtTmp; SNTP_SERVERS = *smtTmp;
} }
smtTmp = sectionEntries (secConfig, SECTION_RPC_STARTUP); smtTmp = SectionEntries (secConfig, SECTION_RPC_STARTUP);
if (smtTmp) if (smtTmp)
{ {
@@ -350,45 +350,45 @@ void Config::load ()
} }
} }
if (sectionSingleB (secConfig, SECTION_DATABASE_PATH, DATABASE_PATH)) if (SectionSingleB (secConfig, SECTION_DATABASE_PATH, DATABASE_PATH))
DATA_DIR = DATABASE_PATH; DATA_DIR = DATABASE_PATH;
(void) sectionSingleB (secConfig, SECTION_VALIDATORS_SITE, VALIDATORS_SITE); (void) SectionSingleB (secConfig, SECTION_VALIDATORS_SITE, VALIDATORS_SITE);
(void) sectionSingleB (secConfig, SECTION_PEER_IP, PEER_IP); (void) SectionSingleB (secConfig, SECTION_PEER_IP, PEER_IP);
if (sectionSingleB (secConfig, SECTION_PEER_PORT, strTemp)) if (SectionSingleB (secConfig, SECTION_PEER_PORT, strTemp))
PEER_PORT = boost::lexical_cast<int> (strTemp); PEER_PORT = boost::lexical_cast<int> (strTemp);
if (sectionSingleB (secConfig, SECTION_PEER_PRIVATE, strTemp)) if (SectionSingleB (secConfig, SECTION_PEER_PRIVATE, strTemp))
PEER_PRIVATE = boost::lexical_cast<bool> (strTemp); PEER_PRIVATE = boost::lexical_cast<bool> (strTemp);
smtTmp = sectionEntries (secConfig, SECTION_RPC_ADMIN_ALLOW); smtTmp = SectionEntries (secConfig, SECTION_RPC_ADMIN_ALLOW);
if (smtTmp) if (smtTmp)
{ {
RPC_ADMIN_ALLOW = *smtTmp; RPC_ADMIN_ALLOW = *smtTmp;
} }
(void) sectionSingleB (secConfig, SECTION_RPC_ADMIN_PASSWORD, RPC_ADMIN_PASSWORD); (void) SectionSingleB (secConfig, SECTION_RPC_ADMIN_PASSWORD, RPC_ADMIN_PASSWORD);
(void) sectionSingleB (secConfig, SECTION_RPC_ADMIN_USER, RPC_ADMIN_USER); (void) SectionSingleB (secConfig, SECTION_RPC_ADMIN_USER, RPC_ADMIN_USER);
(void) sectionSingleB (secConfig, SECTION_RPC_IP, RPC_IP); (void) SectionSingleB (secConfig, SECTION_RPC_IP, RPC_IP);
(void) sectionSingleB (secConfig, SECTION_RPC_PASSWORD, RPC_PASSWORD); (void) SectionSingleB (secConfig, SECTION_RPC_PASSWORD, RPC_PASSWORD);
(void) sectionSingleB (secConfig, SECTION_RPC_USER, RPC_USER); (void) SectionSingleB (secConfig, SECTION_RPC_USER, RPC_USER);
(void) sectionSingleB (secConfig, SECTION_NODE_DB, NODE_DB); (void) SectionSingleB (secConfig, SECTION_NODE_DB, NODE_DB);
(void) sectionSingleB (secConfig, SECTION_LDB_EPHEMERAL, LDB_EPHEMERAL); (void) SectionSingleB (secConfig, SECTION_LDB_EPHEMERAL, LDB_EPHEMERAL);
if (sectionSingleB (secConfig, SECTION_RPC_PORT, strTemp)) if (SectionSingleB (secConfig, SECTION_RPC_PORT, strTemp))
RPC_PORT = boost::lexical_cast<int> (strTemp); RPC_PORT = boost::lexical_cast<int> (strTemp);
if (sectionSingleB (secConfig, "ledger_creator" , strTemp)) if (SectionSingleB (secConfig, "ledger_creator" , strTemp))
LEDGER_CREATOR = boost::lexical_cast<bool> (strTemp); LEDGER_CREATOR = boost::lexical_cast<bool> (strTemp);
if (sectionSingleB (secConfig, SECTION_RPC_ALLOW_REMOTE, strTemp)) if (SectionSingleB (secConfig, SECTION_RPC_ALLOW_REMOTE, strTemp))
RPC_ALLOW_REMOTE = boost::lexical_cast<bool> (strTemp); RPC_ALLOW_REMOTE = boost::lexical_cast<bool> (strTemp);
if (sectionSingleB (secConfig, SECTION_NODE_SIZE, strTemp)) if (SectionSingleB (secConfig, SECTION_NODE_SIZE, strTemp))
{ {
if (strTemp == "tiny") if (strTemp == "tiny")
NODE_SIZE = 0; NODE_SIZE = 0;
@@ -411,47 +411,47 @@ void Config::load ()
} }
} }
if (sectionSingleB (secConfig, SECTION_ELB_SUPPORT, strTemp)) if (SectionSingleB (secConfig, SECTION_ELB_SUPPORT, strTemp))
ELB_SUPPORT = boost::lexical_cast<bool> (strTemp); ELB_SUPPORT = boost::lexical_cast<bool> (strTemp);
(void) sectionSingleB (secConfig, SECTION_WEBSOCKET_IP, WEBSOCKET_IP); (void) SectionSingleB (secConfig, SECTION_WEBSOCKET_IP, WEBSOCKET_IP);
if (sectionSingleB (secConfig, SECTION_WEBSOCKET_PORT, strTemp)) if (SectionSingleB (secConfig, SECTION_WEBSOCKET_PORT, strTemp))
WEBSOCKET_PORT = boost::lexical_cast<int> (strTemp); WEBSOCKET_PORT = boost::lexical_cast<int> (strTemp);
(void) sectionSingleB (secConfig, SECTION_WEBSOCKET_PUBLIC_IP, WEBSOCKET_PUBLIC_IP); (void) SectionSingleB (secConfig, SECTION_WEBSOCKET_PUBLIC_IP, WEBSOCKET_PUBLIC_IP);
if (sectionSingleB (secConfig, SECTION_WEBSOCKET_PUBLIC_PORT, strTemp)) if (SectionSingleB (secConfig, SECTION_WEBSOCKET_PUBLIC_PORT, strTemp))
WEBSOCKET_PUBLIC_PORT = boost::lexical_cast<int> (strTemp); WEBSOCKET_PUBLIC_PORT = boost::lexical_cast<int> (strTemp);
if (sectionSingleB (secConfig, SECTION_WEBSOCKET_SECURE, strTemp)) if (SectionSingleB (secConfig, SECTION_WEBSOCKET_SECURE, strTemp))
WEBSOCKET_SECURE = boost::lexical_cast<int> (strTemp); WEBSOCKET_SECURE = boost::lexical_cast<int> (strTemp);
if (sectionSingleB (secConfig, SECTION_WEBSOCKET_PUBLIC_SECURE, strTemp)) if (SectionSingleB (secConfig, SECTION_WEBSOCKET_PUBLIC_SECURE, strTemp))
WEBSOCKET_PUBLIC_SECURE = boost::lexical_cast<int> (strTemp); WEBSOCKET_PUBLIC_SECURE = boost::lexical_cast<int> (strTemp);
if (sectionSingleB (secConfig, SECTION_WEBSOCKET_PING_FREQ, strTemp)) if (SectionSingleB (secConfig, SECTION_WEBSOCKET_PING_FREQ, strTemp))
WEBSOCKET_PING_FREQ = boost::lexical_cast<int> (strTemp); WEBSOCKET_PING_FREQ = boost::lexical_cast<int> (strTemp);
sectionSingleB (secConfig, SECTION_WEBSOCKET_SSL_CERT, WEBSOCKET_SSL_CERT); SectionSingleB (secConfig, SECTION_WEBSOCKET_SSL_CERT, WEBSOCKET_SSL_CERT);
sectionSingleB (secConfig, SECTION_WEBSOCKET_SSL_CHAIN, WEBSOCKET_SSL_CHAIN); SectionSingleB (secConfig, SECTION_WEBSOCKET_SSL_CHAIN, WEBSOCKET_SSL_CHAIN);
sectionSingleB (secConfig, SECTION_WEBSOCKET_SSL_KEY, WEBSOCKET_SSL_KEY); SectionSingleB (secConfig, SECTION_WEBSOCKET_SSL_KEY, WEBSOCKET_SSL_KEY);
if (sectionSingleB (secConfig, SECTION_RPC_SECURE, strTemp)) if (SectionSingleB (secConfig, SECTION_RPC_SECURE, strTemp))
RPC_SECURE = boost::lexical_cast<int> (strTemp); RPC_SECURE = boost::lexical_cast<int> (strTemp);
sectionSingleB (secConfig, SECTION_RPC_SSL_CERT, RPC_SSL_CERT); SectionSingleB (secConfig, SECTION_RPC_SSL_CERT, RPC_SSL_CERT);
sectionSingleB (secConfig, SECTION_RPC_SSL_CHAIN, RPC_SSL_CHAIN); SectionSingleB (secConfig, SECTION_RPC_SSL_CHAIN, RPC_SSL_CHAIN);
sectionSingleB (secConfig, SECTION_RPC_SSL_KEY, RPC_SSL_KEY); SectionSingleB (secConfig, SECTION_RPC_SSL_KEY, RPC_SSL_KEY);
sectionSingleB (secConfig, SECTION_SSL_VERIFY_FILE, SSL_VERIFY_FILE); SectionSingleB (secConfig, SECTION_SSL_VERIFY_FILE, SSL_VERIFY_FILE);
sectionSingleB (secConfig, SECTION_SSL_VERIFY_DIR, SSL_VERIFY_DIR); SectionSingleB (secConfig, SECTION_SSL_VERIFY_DIR, SSL_VERIFY_DIR);
if (sectionSingleB (secConfig, SECTION_SSL_VERIFY, strTemp)) if (SectionSingleB (secConfig, SECTION_SSL_VERIFY, strTemp))
SSL_VERIFY = boost::lexical_cast<bool> (strTemp); SSL_VERIFY = boost::lexical_cast<bool> (strTemp);
if (sectionSingleB (secConfig, SECTION_VALIDATION_SEED, strTemp)) if (SectionSingleB (secConfig, SECTION_VALIDATION_SEED, strTemp))
{ {
VALIDATION_SEED.setSeedGeneric (strTemp); VALIDATION_SEED.setSeedGeneric (strTemp);
@@ -462,7 +462,7 @@ void Config::load ()
} }
} }
if (sectionSingleB (secConfig, SECTION_NODE_SEED, strTemp)) if (SectionSingleB (secConfig, SECTION_NODE_SEED, strTemp))
{ {
NODE_SEED.setSeedGeneric (strTemp); NODE_SEED.setSeedGeneric (strTemp);
@@ -473,43 +473,43 @@ void Config::load ()
} }
} }
(void) sectionSingleB (secConfig, SECTION_PEER_SSL_CIPHER_LIST, PEER_SSL_CIPHER_LIST); (void) SectionSingleB (secConfig, SECTION_PEER_SSL_CIPHER_LIST, PEER_SSL_CIPHER_LIST);
if (sectionSingleB (secConfig, SECTION_PEER_SCAN_INTERVAL_MIN, strTemp)) if (SectionSingleB (secConfig, SECTION_PEER_SCAN_INTERVAL_MIN, strTemp))
// Minimum for min is 60 seconds. // Minimum for min is 60 seconds.
PEER_SCAN_INTERVAL_MIN = std::max (60, boost::lexical_cast<int> (strTemp)); PEER_SCAN_INTERVAL_MIN = std::max (60, boost::lexical_cast<int> (strTemp));
if (sectionSingleB (secConfig, SECTION_PEER_START_MAX, strTemp)) if (SectionSingleB (secConfig, SECTION_PEER_START_MAX, strTemp))
PEER_START_MAX = std::max (1, boost::lexical_cast<int> (strTemp)); PEER_START_MAX = std::max (1, boost::lexical_cast<int> (strTemp));
if (sectionSingleB (secConfig, SECTION_PEER_CONNECT_LOW_WATER, strTemp)) if (SectionSingleB (secConfig, SECTION_PEER_CONNECT_LOW_WATER, strTemp))
PEER_CONNECT_LOW_WATER = std::max (1, boost::lexical_cast<int> (strTemp)); PEER_CONNECT_LOW_WATER = std::max (1, boost::lexical_cast<int> (strTemp));
if (sectionSingleB (secConfig, SECTION_NETWORK_QUORUM, strTemp)) if (SectionSingleB (secConfig, SECTION_NETWORK_QUORUM, strTemp))
NETWORK_QUORUM = std::max (0, boost::lexical_cast<int> (strTemp)); NETWORK_QUORUM = std::max (0, boost::lexical_cast<int> (strTemp));
if (sectionSingleB (secConfig, SECTION_VALIDATION_QUORUM, strTemp)) if (SectionSingleB (secConfig, SECTION_VALIDATION_QUORUM, strTemp))
VALIDATION_QUORUM = std::max (0, boost::lexical_cast<int> (strTemp)); VALIDATION_QUORUM = std::max (0, boost::lexical_cast<int> (strTemp));
if (sectionSingleB (secConfig, SECTION_FEE_ACCOUNT_RESERVE, strTemp)) if (SectionSingleB (secConfig, SECTION_FEE_ACCOUNT_RESERVE, strTemp))
FEE_ACCOUNT_RESERVE = boost::lexical_cast<uint64> (strTemp); FEE_ACCOUNT_RESERVE = boost::lexical_cast<uint64> (strTemp);
if (sectionSingleB (secConfig, SECTION_FEE_OWNER_RESERVE, strTemp)) if (SectionSingleB (secConfig, SECTION_FEE_OWNER_RESERVE, strTemp))
FEE_OWNER_RESERVE = boost::lexical_cast<uint64> (strTemp); FEE_OWNER_RESERVE = boost::lexical_cast<uint64> (strTemp);
if (sectionSingleB (secConfig, SECTION_FEE_NICKNAME_CREATE, strTemp)) if (SectionSingleB (secConfig, SECTION_FEE_NICKNAME_CREATE, strTemp))
FEE_NICKNAME_CREATE = boost::lexical_cast<int> (strTemp); FEE_NICKNAME_CREATE = boost::lexical_cast<int> (strTemp);
if (sectionSingleB (secConfig, SECTION_FEE_OFFER, strTemp)) if (SectionSingleB (secConfig, SECTION_FEE_OFFER, strTemp))
FEE_OFFER = boost::lexical_cast<int> (strTemp); FEE_OFFER = boost::lexical_cast<int> (strTemp);
if (sectionSingleB (secConfig, SECTION_FEE_DEFAULT, strTemp)) if (SectionSingleB (secConfig, SECTION_FEE_DEFAULT, strTemp))
FEE_DEFAULT = boost::lexical_cast<int> (strTemp); FEE_DEFAULT = boost::lexical_cast<int> (strTemp);
if (sectionSingleB (secConfig, SECTION_FEE_OPERATION, strTemp)) if (SectionSingleB (secConfig, SECTION_FEE_OPERATION, strTemp))
FEE_CONTRACT_OPERATION = boost::lexical_cast<int> (strTemp); FEE_CONTRACT_OPERATION = boost::lexical_cast<int> (strTemp);
if (sectionSingleB (secConfig, SECTION_LEDGER_HISTORY, strTemp)) if (SectionSingleB (secConfig, SECTION_LEDGER_HISTORY, strTemp))
{ {
boost::to_lower (strTemp); boost::to_lower (strTemp);
@@ -521,22 +521,22 @@ void Config::load ()
LEDGER_HISTORY = boost::lexical_cast<uint32> (strTemp); LEDGER_HISTORY = boost::lexical_cast<uint32> (strTemp);
} }
if (sectionSingleB (secConfig, SECTION_PATH_SEARCH_SIZE, strTemp)) if (SectionSingleB (secConfig, SECTION_PATH_SEARCH_SIZE, strTemp))
PATH_SEARCH_SIZE = boost::lexical_cast<int> (strTemp); PATH_SEARCH_SIZE = boost::lexical_cast<int> (strTemp);
if (sectionSingleB (secConfig, SECTION_ACCOUNT_PROBE_MAX, strTemp)) if (SectionSingleB (secConfig, SECTION_ACCOUNT_PROBE_MAX, strTemp))
ACCOUNT_PROBE_MAX = boost::lexical_cast<int> (strTemp); ACCOUNT_PROBE_MAX = boost::lexical_cast<int> (strTemp);
(void) sectionSingleB (secConfig, SECTION_SMS_FROM, SMS_FROM); (void) SectionSingleB (secConfig, SECTION_SMS_FROM, SMS_FROM);
(void) sectionSingleB (secConfig, SECTION_SMS_KEY, SMS_KEY); (void) SectionSingleB (secConfig, SECTION_SMS_KEY, SMS_KEY);
(void) sectionSingleB (secConfig, SECTION_SMS_SECRET, SMS_SECRET); (void) SectionSingleB (secConfig, SECTION_SMS_SECRET, SMS_SECRET);
(void) sectionSingleB (secConfig, SECTION_SMS_TO, SMS_TO); (void) SectionSingleB (secConfig, SECTION_SMS_TO, SMS_TO);
(void) sectionSingleB (secConfig, SECTION_SMS_URL, SMS_URL); (void) SectionSingleB (secConfig, SECTION_SMS_URL, SMS_URL);
if (sectionSingleB (secConfig, SECTION_VALIDATORS_FILE, strTemp)) if (SectionSingleB (secConfig, SECTION_VALIDATORS_FILE, strTemp))
VALIDATORS_FILE = strTemp; VALIDATORS_FILE = strTemp;
if (sectionSingleB (secConfig, SECTION_DEBUG_LOGFILE, strTemp)) if (SectionSingleB (secConfig, SECTION_DEBUG_LOGFILE, strTemp))
DEBUG_LOGFILE = strTemp; DEBUG_LOGFILE = strTemp;
} }
} }

View File

@@ -103,15 +103,15 @@ private:
void fetchProcess (std::string strDomain); void fetchProcess (std::string strDomain);
void fetchTimerHandler (const boost::system::error_code& err); void fetchTimerHandler (const boost::system::error_code& err);
void getValidatorsUrl (const RippleAddress& naNodePublic, section secSite); void getValidatorsUrl (const RippleAddress& naNodePublic, Section secSite);
void getIpsUrl (const RippleAddress& naNodePublic, section secSite); void getIpsUrl (const RippleAddress& naNodePublic, Section secSite);
bool responseIps (const std::string& strSite, const RippleAddress& naNodePublic, const boost::system::error_code& err, int iStatus, const std::string& strIpsFile); bool responseIps (const std::string& strSite, const RippleAddress& naNodePublic, const boost::system::error_code& err, int iStatus, const std::string& strIpsFile);
bool responseValidators (const std::string& strValidatorsUrl, const RippleAddress& naNodePublic, section secSite, const std::string& strSite, const boost::system::error_code& err, int iStatus, const std::string& strValidatorsFile); bool responseValidators (const std::string& strValidatorsUrl, const RippleAddress& naNodePublic, Section secSite, const std::string& strSite, const boost::system::error_code& err, int iStatus, const std::string& strValidatorsFile);
void processIps (const std::string& strSite, const RippleAddress& naNodePublic, section::mapped_type* pmtVecStrIps); void processIps (const std::string& strSite, const RippleAddress& naNodePublic, Section::mapped_type* pmtVecStrIps);
int processValidators (const std::string& strSite, const std::string& strValidatorsSrc, const RippleAddress& naNodePublic, validatorSource vsWhy, section::mapped_type* pmtVecStrValidators); int processValidators (const std::string& strSite, const std::string& strValidatorsSrc, const RippleAddress& naNodePublic, validatorSource vsWhy, Section::mapped_type* pmtVecStrValidators);
void processFile (const std::string& strDomain, const RippleAddress& naNodePublic, section secSite); void processFile (const std::string& strDomain, const RippleAddress& naNodePublic, Section secSite);
bool getSeedDomains (const std::string& strDomain, seedDomain& dstSeedDomain); bool getSeedDomains (const std::string& strDomain, seedDomain& dstSeedDomain);
void setSeedDomains (const seedDomain& dstSeedDomain, bool bNext); void setSeedDomains (const seedDomain& dstSeedDomain, bool bNext);
@@ -759,7 +759,7 @@ void UniqueNodeList::fetchDirty ()
// Persist the IPs refered to by a Validator. // Persist the IPs refered to by a Validator.
// --> strSite: source of the IPs (for debugging) // --> strSite: source of the IPs (for debugging)
// --> naNodePublic: public key of the validating node. // --> naNodePublic: public key of the validating node.
void UniqueNodeList::processIps (const std::string& strSite, const RippleAddress& naNodePublic, section::mapped_type* pmtVecStrIps) void UniqueNodeList::processIps (const std::string& strSite, const RippleAddress& naNodePublic, Section::mapped_type* pmtVecStrIps)
{ {
Database* db = theApp->getWalletDB ()->getDB (); Database* db = theApp->getWalletDB ()->getDB ();
@@ -829,7 +829,7 @@ void UniqueNodeList::processIps (const std::string& strSite, const RippleAddress
// --> strValidatorsSrc: source details for display // --> strValidatorsSrc: source details for display
// --> naNodePublic: remote source public key - not valid for local // --> naNodePublic: remote source public key - not valid for local
// --> vsWhy: reason for adding validator to SeedDomains or SeedNodes. // --> vsWhy: reason for adding validator to SeedDomains or SeedNodes.
int UniqueNodeList::processValidators (const std::string& strSite, const std::string& strValidatorsSrc, const RippleAddress& naNodePublic, validatorSource vsWhy, section::mapped_type* pmtVecStrValidators) int UniqueNodeList::processValidators (const std::string& strSite, const std::string& strValidatorsSrc, const RippleAddress& naNodePublic, validatorSource vsWhy, Section::mapped_type* pmtVecStrValidators)
{ {
Database* db = theApp->getWalletDB ()->getDB (); Database* db = theApp->getWalletDB ()->getDB ();
std::string strNodePublic = naNodePublic.isValid () ? naNodePublic.humanNodePublic () : strValidatorsSrc; std::string strNodePublic = naNodePublic.isValid () ? naNodePublic.humanNodePublic () : strValidatorsSrc;
@@ -927,7 +927,7 @@ int UniqueNodeList::processValidators (const std::string& strSite, const std::st
return iValues; return iValues;
} }
// Given a section with IPs, parse and persist it for a validator. // Given a Section with IPs, parse and persist it for a validator.
bool UniqueNodeList::responseIps (const std::string& strSite, const RippleAddress& naNodePublic, const boost::system::error_code& err, int iStatus, const std::string& strIpsFile) bool UniqueNodeList::responseIps (const std::string& strSite, const RippleAddress& naNodePublic, const boost::system::error_code& err, int iStatus, const std::string& strIpsFile)
{ {
bool bReject = !err && iStatus != 200; bool bReject = !err && iStatus != 200;
@@ -936,9 +936,9 @@ bool UniqueNodeList::responseIps (const std::string& strSite, const RippleAddres
{ {
if (!err) if (!err)
{ {
section secFile = ParseSection (strIpsFile, true); Section secFile = ParseSection (strIpsFile, true);
processIps (strSite, naNodePublic, sectionEntries (secFile, SECTION_IPS)); processIps (strSite, naNodePublic, SectionEntries (secFile, SECTION_IPS));
} }
fetchFinish (); fetchFinish ();
@@ -947,9 +947,9 @@ bool UniqueNodeList::responseIps (const std::string& strSite, const RippleAddres
return bReject; return bReject;
} }
// Process section [ips_url]. // Process Section [ips_url].
// If we have a section with a single entry, fetch the url and process it. // If we have a Section with a single entry, fetch the url and process it.
void UniqueNodeList::getIpsUrl (const RippleAddress& naNodePublic, section secSite) void UniqueNodeList::getIpsUrl (const RippleAddress& naNodePublic, Section secSite)
{ {
std::string strIpsUrl; std::string strIpsUrl;
std::string strScheme; std::string strScheme;
@@ -957,7 +957,7 @@ void UniqueNodeList::getIpsUrl (const RippleAddress& naNodePublic, section secSi
int iPort; int iPort;
std::string strPath; std::string strPath;
if (sectionSingleB (secSite, SECTION_IPS_URL, strIpsUrl) if (SectionSingleB (secSite, SECTION_IPS_URL, strIpsUrl)
&& !strIpsUrl.empty () && !strIpsUrl.empty ()
&& parseUrl (strIpsUrl, strScheme, strDomain, iPort, strPath) && parseUrl (strIpsUrl, strScheme, strDomain, iPort, strPath)
&& -1 == iPort && -1 == iPort
@@ -979,8 +979,8 @@ void UniqueNodeList::getIpsUrl (const RippleAddress& naNodePublic, section secSi
} }
} }
// After fetching a ripple.txt from a web site, given a section with validators, parse and persist it. // After fetching a ripple.txt from a web site, given a Section with validators, parse and persist it.
bool UniqueNodeList::responseValidators (const std::string& strValidatorsUrl, const RippleAddress& naNodePublic, section secSite, const std::string& strSite, const boost::system::error_code& err, int iStatus, const std::string& strValidatorsFile) bool UniqueNodeList::responseValidators (const std::string& strValidatorsUrl, const RippleAddress& naNodePublic, Section secSite, const std::string& strSite, const boost::system::error_code& err, int iStatus, const std::string& strValidatorsFile)
{ {
bool bReject = !err && iStatus != 200; bool bReject = !err && iStatus != 200;
@@ -988,9 +988,9 @@ bool UniqueNodeList::responseValidators (const std::string& strValidatorsUrl, co
{ {
if (!err) if (!err)
{ {
section secFile = ParseSection (strValidatorsFile, true); Section secFile = ParseSection (strValidatorsFile, true);
processValidators (strSite, strValidatorsUrl, naNodePublic, vsValidator, sectionEntries (secFile, SECTION_VALIDATORS)); processValidators (strSite, strValidatorsUrl, naNodePublic, vsValidator, SectionEntries (secFile, SECTION_VALIDATORS));
} }
getIpsUrl (naNodePublic, secSite); getIpsUrl (naNodePublic, secSite);
@@ -999,8 +999,8 @@ bool UniqueNodeList::responseValidators (const std::string& strValidatorsUrl, co
return bReject; return bReject;
} }
// Process section [validators_url]. // Process Section [validators_url].
void UniqueNodeList::getValidatorsUrl (const RippleAddress& naNodePublic, section secSite) void UniqueNodeList::getValidatorsUrl (const RippleAddress& naNodePublic, Section secSite)
{ {
std::string strValidatorsUrl; std::string strValidatorsUrl;
std::string strScheme; std::string strScheme;
@@ -1008,7 +1008,7 @@ void UniqueNodeList::getValidatorsUrl (const RippleAddress& naNodePublic, sectio
int iPort; int iPort;
std::string strPath; std::string strPath;
if (sectionSingleB (secSite, SECTION_VALIDATORS_URL, strValidatorsUrl) if (SectionSingleB (secSite, SECTION_VALIDATORS_URL, strValidatorsUrl)
&& !strValidatorsUrl.empty () && !strValidatorsUrl.empty ()
&& parseUrl (strValidatorsUrl, strScheme, strDomain, iPort, strPath) && parseUrl (strValidatorsUrl, strScheme, strDomain, iPort, strPath)
&& -1 == iPort && -1 == iPort
@@ -1031,24 +1031,24 @@ void UniqueNodeList::getValidatorsUrl (const RippleAddress& naNodePublic, sectio
} }
// Process a ripple.txt. // Process a ripple.txt.
void UniqueNodeList::processFile (const std::string& strDomain, const RippleAddress& naNodePublic, section secSite) void UniqueNodeList::processFile (const std::string& strDomain, const RippleAddress& naNodePublic, Section secSite)
{ {
// //
// Process Validators // Process Validators
// //
processValidators (strDomain, NODE_FILE_NAME, naNodePublic, vsReferral, sectionEntries (secSite, SECTION_VALIDATORS)); processValidators (strDomain, NODE_FILE_NAME, naNodePublic, vsReferral, SectionEntries (secSite, SECTION_VALIDATORS));
// //
// Process ips // Process ips
// //
processIps (strDomain, naNodePublic, sectionEntries (secSite, SECTION_IPS)); processIps (strDomain, naNodePublic, SectionEntries (secSite, SECTION_IPS));
// //
// Process currencies // Process currencies
// //
section::mapped_type* pvCurrencies; Section::mapped_type* pvCurrencies;
if ((pvCurrencies = sectionEntries (secSite, SECTION_CURRENCIES)) && pvCurrencies->size ()) if ((pvCurrencies = SectionEntries (secSite, SECTION_CURRENCIES)) && pvCurrencies->size ())
{ {
// XXX Process currencies. // XXX Process currencies.
WriteLog (lsWARNING, UniqueNodeList) << "Ignoring currencies: not implemented."; WriteLog (lsWARNING, UniqueNodeList) << "Ignoring currencies: not implemented.";
@@ -1064,7 +1064,7 @@ bool UniqueNodeList::responseFetch (const std::string& strDomain, const boost::s
if (!bReject) if (!bReject)
{ {
section secSite = ParseSection (strSiteFile, true); Section secSite = ParseSection (strSiteFile, true);
bool bGood = !err; bool bGood = !err;
if (bGood) if (bGood)
@@ -1084,7 +1084,7 @@ bool UniqueNodeList::responseFetch (const std::string& strDomain, const boost::s
// //
std::string strSite; std::string strSite;
if (bGood && !sectionSingleB (secSite, SECTION_DOMAIN, strSite)) if (bGood && !SectionSingleB (secSite, SECTION_DOMAIN, strSite))
{ {
bGood = false; bGood = false;
@@ -1108,9 +1108,9 @@ bool UniqueNodeList::responseFetch (const std::string& strDomain, const boost::s
// //
std::string strNodePublicKey; std::string strNodePublicKey;
if (bGood && !sectionSingleB (secSite, SECTION_PUBLIC_KEY, strNodePublicKey)) if (bGood && !SectionSingleB (secSite, SECTION_PUBLIC_KEY, strNodePublicKey))
{ {
// Bad [validation_public_key] section. // Bad [validation_public_key] Section.
bGood = false; bGood = false;
WriteLog (lsTRACE, UniqueNodeList) WriteLog (lsTRACE, UniqueNodeList)
@@ -1875,9 +1875,9 @@ void UniqueNodeList::nodeBootstrap ()
// --> strValidators: contents of a validators.txt // --> strValidators: contents of a validators.txt
void UniqueNodeList::nodeProcess (const std::string& strSite, const std::string& strValidators, const std::string& strSource) void UniqueNodeList::nodeProcess (const std::string& strSite, const std::string& strValidators, const std::string& strSource)
{ {
section secValidators = ParseSection (strValidators, true); Section secValidators = ParseSection (strValidators, true);
section::mapped_type* pmtEntries = sectionEntries (secValidators, SECTION_VALIDATORS); Section::mapped_type* pmtEntries = SectionEntries (secValidators, SECTION_VALIDATORS);
if (pmtEntries) if (pmtEntries)
{ {