mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-22 12:05:53 +00:00
Begin work on fetch_info command.
This commit is contained in:
@@ -263,4 +263,35 @@ void InboundLedgers::gotFetchPack (Job&)
|
||||
}
|
||||
}
|
||||
|
||||
void InboundLedgers::clearFailures ()
|
||||
{
|
||||
boost::mutex::scoped_lock sl (mLock);
|
||||
|
||||
mRecentFailures.clear();
|
||||
mLedgers.clear();
|
||||
}
|
||||
|
||||
Json::Value InboundLedgers::getInfo()
|
||||
{
|
||||
Json::Value ret(Json::objectValue);
|
||||
boost::mutex::scoped_lock sl (mLock);
|
||||
|
||||
std::vector<InboundLedger::pointer> acquires;
|
||||
{
|
||||
boost::mutex::scoped_lock sl (mLock);
|
||||
|
||||
acquires.reserve (mLedgers.size ());
|
||||
typedef std::pair<uint256, InboundLedger::pointer> u256_acq_pair;
|
||||
BOOST_FOREACH (const u256_acq_pair & it, mLedgers)
|
||||
acquires.push_back (it.second);
|
||||
}
|
||||
|
||||
BOOST_FOREACH (const InboundLedger::pointer & acquire, acquires)
|
||||
{
|
||||
// WRITEME
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
// vim:ts=4
|
||||
|
||||
@@ -56,6 +56,10 @@ public:
|
||||
return mRecentFailures.isPresent (h, false);
|
||||
}
|
||||
|
||||
void clearFailures();
|
||||
|
||||
Json::Value getInfo();
|
||||
|
||||
void gotFetchPack (Job&);
|
||||
void sweep ();
|
||||
|
||||
|
||||
@@ -148,6 +148,14 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Empty the cache
|
||||
*/
|
||||
void clear ()
|
||||
{
|
||||
boost::mutex::scoped_lock sl (mNCLock);
|
||||
mCache.clear ();
|
||||
}
|
||||
|
||||
/** Remove stale entries from the cache.
|
||||
*/
|
||||
void sweep ()
|
||||
|
||||
@@ -116,6 +116,18 @@ Json::Value RPCParser::parseInternal (const Json::Value& jvParams)
|
||||
return v;
|
||||
}
|
||||
|
||||
// fetch_info [clear]
|
||||
Json::Value RPCParser::parseFetchInfo (const Json::Value& jvParams)
|
||||
{
|
||||
Json::Value jvRequest (Json::objectValue);
|
||||
unsigned int iParams = jvParams.size ();
|
||||
|
||||
if (iParams != 0)
|
||||
jvRequest[jvParams[0u].asString()] = true;
|
||||
|
||||
return jvRequest;
|
||||
}
|
||||
|
||||
// account_tx accountID [ledger_min [ledger_max [limit [offset]]]] [binary] [count] [descending]
|
||||
Json::Value RPCParser::parseAccountTransactions (const Json::Value& jvParams)
|
||||
{
|
||||
@@ -743,6 +755,7 @@ Json::Value RPCParser::parseCommand (std::string strMethod, Json::Value jvParams
|
||||
{ "connect", &RPCParser::parseConnect, 1, 2 },
|
||||
{ "consensus_info", &RPCParser::parseAsIs, 0, 0 },
|
||||
{ "feature", &RPCParser::parseFeature, 0, 2 },
|
||||
{ "fetch_info", &RPCParser::parseFetchInfo, 0, 1 },
|
||||
{ "get_counts", &RPCParser::parseGetCounts, 0, 1 },
|
||||
{ "json", &RPCParser::parseJson, 2, 2 },
|
||||
{ "ledger", &RPCParser::parseLedger, 0, 2 },
|
||||
|
||||
@@ -30,6 +30,7 @@ private:
|
||||
#endif
|
||||
Json::Value parseEvented (const Json::Value& jvParams);
|
||||
Json::Value parseFeature (const Json::Value& jvParams);
|
||||
Json::Value parseFetchInfo (const Json::Value& jvParams);
|
||||
Json::Value parseGetCounts (const Json::Value& jvParams);
|
||||
Json::Value parseInternal (const Json::Value& jvParams);
|
||||
Json::Value parseJson (const Json::Value& jvParams);
|
||||
|
||||
@@ -1511,6 +1511,16 @@ Json::Value NetworkOPs::getServerInfo (bool human, bool admin)
|
||||
return info;
|
||||
}
|
||||
|
||||
void NetworkOPs::clearLedgerFetch ()
|
||||
{
|
||||
getApp().getInboundLedgers().clearFailures();
|
||||
}
|
||||
|
||||
Json::Value NetworkOPs::getLedgerFetchInfo ()
|
||||
{
|
||||
return getApp().getInboundLedgers().getInfo();
|
||||
}
|
||||
|
||||
//
|
||||
// Monitoring: publisher side
|
||||
//
|
||||
|
||||
@@ -302,6 +302,8 @@ public:
|
||||
}
|
||||
Json::Value getConsensusInfo ();
|
||||
Json::Value getServerInfo (bool human, bool admin);
|
||||
void clearLedgerFetch ();
|
||||
Json::Value getLedgerFetchInfo ();
|
||||
uint32 acceptLedger ();
|
||||
boost::unordered_map < uint160,
|
||||
std::list<LedgerProposal::pointer> > & peekStoredProposals ()
|
||||
|
||||
@@ -1749,6 +1749,21 @@ Json::Value RPCHandler::doConsensusInfo (Json::Value, LoadType* loadType, Scoped
|
||||
return ret;
|
||||
}
|
||||
|
||||
Json::Value RPCHandler::doFetchInfo (Json::Value jvParams, LoadType* loadType, ScopedLock& MasterLockHolder)
|
||||
{
|
||||
Json::Value ret (Json::objectValue);
|
||||
|
||||
if (jvParams.isMember("clear") && jvParams["clear"].asBool())
|
||||
{
|
||||
mNetOps->clearLedgerFetch();
|
||||
ret["clear"] = true;
|
||||
}
|
||||
|
||||
ret["info"] = mNetOps->getLedgerFetchInfo();
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
Json::Value RPCHandler::doServerInfo (Json::Value, LoadType* loadType, ScopedLock& MasterLockHolder)
|
||||
{
|
||||
Json::Value ret (Json::objectValue);
|
||||
@@ -3605,6 +3620,7 @@ Json::Value RPCHandler::doCommand (const Json::Value& params, int iRole, LoadTyp
|
||||
{ "get_counts", &RPCHandler::doGetCounts, true, optNone },
|
||||
{ "internal", &RPCHandler::doInternal, true, optNone },
|
||||
{ "feature", &RPCHandler::doFeature, true, optNone },
|
||||
{ "fetch_info", &RPCHandler::doFetchInfo, true, optNone },
|
||||
{ "ledger", &RPCHandler::doLedger, false, optNetwork },
|
||||
{ "ledger_accept", &RPCHandler::doLedgerAccept, true, optCurrent },
|
||||
{ "ledger_closed", &RPCHandler::doLedgerClosed, false, optClosed },
|
||||
|
||||
@@ -97,6 +97,7 @@ private:
|
||||
Json::Value doConnect (Json::Value params, LoadType* loadType, ScopedLock& mlh);
|
||||
Json::Value doConsensusInfo (Json::Value params, LoadType* loadType, ScopedLock& mlh);
|
||||
Json::Value doFeature (Json::Value params, LoadType* loadType, ScopedLock& mlh);
|
||||
Json::Value doFetchInfo (Json::Value params, LoadType* loadType, ScopedLock& mlh);
|
||||
Json::Value doGetCounts (Json::Value params, LoadType* loadType, ScopedLock& mlh);
|
||||
Json::Value doInternal (Json::Value params, LoadType* loadType, ScopedLock& mlh);
|
||||
Json::Value doLedger (Json::Value params, LoadType* loadType, ScopedLock& mlh);
|
||||
|
||||
Reference in New Issue
Block a user