mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-24 13:05:53 +00:00
Fix platform and debug macros
This commit is contained in:
@@ -24,24 +24,44 @@
|
||||
// VFALCO TODO move all function definitions inlined into the class.
|
||||
class UniqueNodeList : public IUniqueNodeList
|
||||
{
|
||||
public:
|
||||
UniqueNodeList (boost::asio::io_service& io_service);
|
||||
|
||||
// Begin processing.
|
||||
void start ();
|
||||
|
||||
void nodeAddPublic (const RippleAddress& naNodePublic, ValidatorSource vsWhy, const std::string& strComment);
|
||||
void nodeAddDomain (std::string strDomain, ValidatorSource vsWhy, const std::string& strComment = "");
|
||||
void nodeRemovePublic (const RippleAddress& naNodePublic);
|
||||
void nodeRemoveDomain (std::string strDomain);
|
||||
void nodeReset ();
|
||||
|
||||
void nodeScore ();
|
||||
|
||||
bool nodeInUNL (const RippleAddress& naNodePublic);
|
||||
bool nodeInCluster (const RippleAddress& naNodePublic);
|
||||
bool nodeInCluster (const RippleAddress& naNodePublic, std::string& name);
|
||||
|
||||
void nodeBootstrap ();
|
||||
bool nodeLoad (boost::filesystem::path pConfig);
|
||||
void nodeNetwork ();
|
||||
|
||||
Json::Value getUnlJson ();
|
||||
|
||||
int iSourceScore (ValidatorSource vsWhy);
|
||||
|
||||
private:
|
||||
// Misc persistent information
|
||||
boost::posix_time::ptime mtpScoreUpdated;
|
||||
boost::posix_time::ptime mtpFetchUpdated;
|
||||
|
||||
boost::recursive_mutex mUNLLock;
|
||||
// XXX Make this faster, make this the contents vector unsigned char or raw public key.
|
||||
// XXX Contents needs to based on score.
|
||||
boost::unordered_set<std::string> mUNL;
|
||||
|
||||
bool miscLoad ();
|
||||
bool miscSave ();
|
||||
|
||||
// VFALCO TODO Rename these structs? Are they objects with static storage?
|
||||
// This looks like C and not C++...
|
||||
//
|
||||
typedef struct
|
||||
{
|
||||
std::string strDomain;
|
||||
RippleAddress naPublicKey;
|
||||
validatorSource vsSource;
|
||||
ValidatorSource vsSource;
|
||||
boost::posix_time::ptime tpNext;
|
||||
boost::posix_time::ptime tpScan;
|
||||
boost::posix_time::ptime tpFetch;
|
||||
@@ -52,7 +72,7 @@ private:
|
||||
typedef struct
|
||||
{
|
||||
RippleAddress naPublicKey;
|
||||
validatorSource vsSource;
|
||||
ValidatorSource vsSource;
|
||||
boost::posix_time::ptime tpNext;
|
||||
boost::posix_time::ptime tpScan;
|
||||
boost::posix_time::ptime tpFetch;
|
||||
@@ -71,10 +91,8 @@ private:
|
||||
std::vector<int> viReferrals;
|
||||
} scoreNode;
|
||||
|
||||
std::map<RippleAddress, std::string> sClusterNodes;
|
||||
|
||||
typedef boost::unordered_map<std::string, int> strIndex;
|
||||
typedef std::pair<std::string, int> ipPort;
|
||||
typedef std::pair<std::string, int> IPAndPortNumber;
|
||||
typedef boost::unordered_map<std::pair< std::string, int>, score> epScore;
|
||||
|
||||
void trustedLoad ();
|
||||
@@ -83,20 +101,10 @@ private:
|
||||
|
||||
bool responseFetch (const std::string& strDomain, const boost::system::error_code& err, int iStatus, const std::string& strSiteFile);
|
||||
|
||||
boost::posix_time::ptime mtpScoreNext; // When to start scoring.
|
||||
boost::posix_time::ptime mtpScoreStart; // Time currently started scoring.
|
||||
boost::asio::deadline_timer mdtScoreTimer; // Timer to start scoring.
|
||||
|
||||
void scoreNext (bool bNow); // Update scoring timer.
|
||||
void scoreCompute ();
|
||||
void scoreTimerHandler (const boost::system::error_code& err);
|
||||
|
||||
boost::mutex mFetchLock;
|
||||
int mFetchActive; // Count of active fetches.
|
||||
|
||||
boost::posix_time::ptime mtpFetchNext; // Time of to start next fetch.
|
||||
boost::asio::deadline_timer mdtFetchTimer; // Timer to start fetching.
|
||||
|
||||
void fetchNext ();
|
||||
void fetchDirty ();
|
||||
void fetchFinish ();
|
||||
@@ -109,7 +117,7 @@ private:
|
||||
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);
|
||||
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);
|
||||
|
||||
@@ -122,31 +130,27 @@ private:
|
||||
bool validatorsResponse (const boost::system::error_code& err, int iStatus, const std::string strResponse);
|
||||
void nodeProcess (const std::string& strSite, const std::string& strValidators, const std::string& strSource);
|
||||
|
||||
public:
|
||||
UniqueNodeList (boost::asio::io_service& io_service);
|
||||
private:
|
||||
// Misc persistent information
|
||||
boost::posix_time::ptime mtpScoreUpdated;
|
||||
boost::posix_time::ptime mtpFetchUpdated;
|
||||
|
||||
// Begin processing.
|
||||
void start ();
|
||||
boost::recursive_mutex mUNLLock;
|
||||
// XXX Make this faster, make this the contents vector unsigned char or raw public key.
|
||||
// XXX Contents needs to based on score.
|
||||
boost::unordered_set<std::string> mUNL;
|
||||
|
||||
void nodeAddPublic (const RippleAddress& naNodePublic, validatorSource vsWhy, const std::string& strComment);
|
||||
void nodeAddDomain (std::string strDomain, validatorSource vsWhy, const std::string& strComment = "");
|
||||
void nodeRemovePublic (const RippleAddress& naNodePublic);
|
||||
void nodeRemoveDomain (std::string strDomain);
|
||||
void nodeReset ();
|
||||
boost::posix_time::ptime mtpScoreNext; // When to start scoring.
|
||||
boost::posix_time::ptime mtpScoreStart; // Time currently started scoring.
|
||||
boost::asio::deadline_timer mdtScoreTimer; // Timer to start scoring.
|
||||
|
||||
void nodeScore ();
|
||||
boost::mutex mFetchLock;
|
||||
int mFetchActive; // Count of active fetches.
|
||||
|
||||
bool nodeInUNL (const RippleAddress& naNodePublic);
|
||||
bool nodeInCluster (const RippleAddress& naNodePublic);
|
||||
bool nodeInCluster (const RippleAddress& naNodePublic, std::string& name);
|
||||
boost::posix_time::ptime mtpFetchNext; // Time of to start next fetch.
|
||||
boost::asio::deadline_timer mdtFetchTimer; // Timer to start fetching.
|
||||
|
||||
void nodeBootstrap ();
|
||||
bool nodeLoad (boost::filesystem::path pConfig);
|
||||
void nodeNetwork ();
|
||||
|
||||
Json::Value getUnlJson ();
|
||||
|
||||
int iSourceScore (validatorSource vsWhy);
|
||||
std::map<RippleAddress, std::string> sClusterNodes;
|
||||
};
|
||||
|
||||
// VFALCO TODO Replace macros with language constructs
|
||||
@@ -347,7 +351,7 @@ void UniqueNodeList::scoreCompute ()
|
||||
std::string strDomain = db->getStrBinary ("Domain");
|
||||
std::string strPublicKey = db->getStrBinary ("PublicKey");
|
||||
std::string strSource = db->getStrBinary ("Source");
|
||||
int iScore = iSourceScore (static_cast<validatorSource> (strSource[0]));
|
||||
int iScore = iSourceScore (static_cast<ValidatorSource> (strSource[0]));
|
||||
strIndex::iterator siOld = umPulicIdx.find (strPublicKey);
|
||||
|
||||
if (siOld == umPulicIdx.end ())
|
||||
@@ -393,7 +397,7 @@ void UniqueNodeList::scoreCompute ()
|
||||
{
|
||||
std::string strPublicKey = db->getStrBinary ("PublicKey");
|
||||
std::string strSource = db->getStrBinary ("Source");
|
||||
int iScore = iSourceScore (static_cast<validatorSource> (strSource[0]));
|
||||
int iScore = iSourceScore (static_cast<ValidatorSource> (strSource[0]));
|
||||
strIndex::iterator siOld = umPulicIdx.find (strPublicKey);
|
||||
|
||||
if (siOld == umPulicIdx.end ())
|
||||
@@ -654,7 +658,7 @@ void UniqueNodeList::scoreCompute ()
|
||||
typedef boost::unordered_map<std::pair< std::string, int>, score>::value_type ipScoreType;
|
||||
BOOST_FOREACH (ipScoreType & ipScore, umScore)
|
||||
{
|
||||
ipPort ipEndpoint = ipScore.first;
|
||||
IPAndPortNumber ipEndpoint = ipScore.first;
|
||||
std::string strIpPort = str (boost::format ("%s %d") % ipEndpoint.first % ipEndpoint.second);
|
||||
score iPoints = ipScore.second;
|
||||
|
||||
@@ -829,7 +833,7 @@ void UniqueNodeList::processIps (const std::string& strSite, const RippleAddress
|
||||
// --> strValidatorsSrc: source details for display
|
||||
// --> naNodePublic: remote source public key - not valid for local
|
||||
// --> 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 = getApp().getWalletDB ()->getDB ();
|
||||
std::string strNodePublic = naNodePublic.isValid () ? naNodePublic.humanNodePublic () : strValidatorsSrc;
|
||||
@@ -1304,7 +1308,7 @@ void UniqueNodeList::fetchNext ()
|
||||
}
|
||||
|
||||
// For each kind of source, have a starting number of points to be distributed.
|
||||
int UniqueNodeList::iSourceScore (validatorSource vsWhy)
|
||||
int UniqueNodeList::iSourceScore (ValidatorSource vsWhy)
|
||||
{
|
||||
int iScore = 0;
|
||||
|
||||
@@ -1339,7 +1343,7 @@ int UniqueNodeList::iSourceScore (validatorSource vsWhy)
|
||||
break;
|
||||
|
||||
default:
|
||||
throw std::runtime_error ("Internal error: bad validatorSource.");
|
||||
throw std::runtime_error ("Internal error: bad ValidatorSource.");
|
||||
}
|
||||
|
||||
return iScore;
|
||||
@@ -1378,7 +1382,7 @@ bool UniqueNodeList::getSeedDomains (const std::string& strDomain, seedDomain& d
|
||||
}
|
||||
|
||||
std::string strSource = db->getStrBinary ("Source");
|
||||
dstSeedDomain.vsSource = static_cast<validatorSource> (strSource[0]);
|
||||
dstSeedDomain.vsSource = static_cast<ValidatorSource> (strSource[0]);
|
||||
|
||||
iNext = db->getInt ("Next");
|
||||
dstSeedDomain.tpNext = ptFromSeconds (iNext);
|
||||
@@ -1444,7 +1448,7 @@ void UniqueNodeList::setSeedDomains (const seedDomain& sdSource, bool bNext)
|
||||
// Queue a domain for a single attempt fetch a ripple.txt.
|
||||
// --> strComment: only used on vsManual
|
||||
// YYY As a lot of these may happen at once, would be nice to wrap multiple calls in a transaction.
|
||||
void UniqueNodeList::nodeAddDomain (std::string strDomain, validatorSource vsWhy, const std::string& strComment)
|
||||
void UniqueNodeList::nodeAddDomain (std::string strDomain, ValidatorSource vsWhy, const std::string& strComment)
|
||||
{
|
||||
boost::trim (strDomain);
|
||||
boost::to_lower (strDomain);
|
||||
@@ -1517,7 +1521,7 @@ bool UniqueNodeList::getSeedNodes (const RippleAddress& naNodePublic, seedNode&
|
||||
}
|
||||
|
||||
strSource = db->getStrBinary ("Source");
|
||||
dstSeedNode.vsSource = static_cast<validatorSource> (strSource[0]);
|
||||
dstSeedNode.vsSource = static_cast<ValidatorSource> (strSource[0]);
|
||||
|
||||
iNext = db->getInt ("Next");
|
||||
dstSeedNode.tpNext = ptFromSeconds (iNext);
|
||||
@@ -1592,7 +1596,7 @@ void UniqueNodeList::setSeedNodes (const seedNode& snSource, bool bNext)
|
||||
}
|
||||
|
||||
// Add a trusted node. Called by RPC or other source.
|
||||
void UniqueNodeList::nodeAddPublic (const RippleAddress& naNodePublic, validatorSource vsWhy, const std::string& strComment)
|
||||
void UniqueNodeList::nodeAddPublic (const RippleAddress& naNodePublic, ValidatorSource vsWhy, const std::string& strComment)
|
||||
{
|
||||
seedNode snCurrent;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user