mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Merge branch 'master' of github.com:jedmccaleb/NewCoin into new_pathfinding
This commit is contained in:
@@ -785,7 +785,7 @@ int commandLineRPC(const std::vector<std::string>& vCmd)
|
||||
: vCmd[0],
|
||||
jvParams, // Parsed, execute.
|
||||
false,
|
||||
boost::bind(callRPCHandler, &jvOutput, _1));
|
||||
BIND_TYPE(callRPCHandler, &jvOutput, P_1));
|
||||
|
||||
isService.run(); // This blocks until there is no more outstanding async calls.
|
||||
|
||||
@@ -848,7 +848,7 @@ int commandLineRPC(const std::vector<std::string>& vCmd)
|
||||
#define RPC_NOTIFY_SECONDS 10
|
||||
|
||||
bool responseRPC(
|
||||
boost::function<void(const Json::Value& jvInput)> callbackFuncP,
|
||||
FUNCTION_TYPE<void(const Json::Value& jvInput)> callbackFuncP,
|
||||
const boost::system::error_code& ecResult, int iStatus, const std::string& strData)
|
||||
{
|
||||
if (callbackFuncP)
|
||||
@@ -886,7 +886,9 @@ bool responseRPC(
|
||||
}
|
||||
|
||||
// Build the request.
|
||||
void requestRPC(const std::string& strMethod, const Json::Value& jvParams, const std::map<std::string, std::string>& mHeaders, const std::string& strPath, boost::asio::streambuf& sb, const std::string& strHost)
|
||||
void requestRPC(const std::string& strMethod, const Json::Value& jvParams,
|
||||
const std::map<std::string, std::string>& mHeaders, const std::string& strPath,
|
||||
boost::asio::streambuf& sb, const std::string& strHost)
|
||||
{
|
||||
cLog(lsDEBUG) << "requestRPC: strPath='" << strPath << "'";
|
||||
|
||||
@@ -906,7 +908,7 @@ void callRPC(
|
||||
const std::string& strUsername, const std::string& strPassword,
|
||||
const std::string& strPath, const std::string& strMethod,
|
||||
const Json::Value& jvParams, const bool bSSL,
|
||||
boost::function<void(const Json::Value& jvInput)> callbackFuncP)
|
||||
FUNCTION_TYPE<void(const Json::Value& jvInput)> callbackFuncP)
|
||||
{
|
||||
// Connect to localhost
|
||||
if (!theConfig.QUIET)
|
||||
@@ -933,15 +935,15 @@ void callRPC(
|
||||
io_service,
|
||||
strIp,
|
||||
iPort,
|
||||
boost::bind(
|
||||
BIND_TYPE(
|
||||
&requestRPC,
|
||||
strMethod,
|
||||
jvParams,
|
||||
mapRequestHeaders,
|
||||
strPath, _1, _2),
|
||||
strPath, P_1, P_2),
|
||||
RPC_REPLY_MAX_BYTES,
|
||||
boost::posix_time::seconds(RPC_NOTIFY_SECONDS),
|
||||
boost::bind(&responseRPC, callbackFuncP, _1, _2, _3));
|
||||
BIND_TYPE(&responseRPC, callbackFuncP, P_1, P_2, P_3));
|
||||
}
|
||||
|
||||
// vim:ts=4
|
||||
|
||||
@@ -56,7 +56,7 @@ extern void callRPC(
|
||||
const std::string& strUsername, const std::string& strPassword,
|
||||
const std::string& strPath, const std::string& strMethod,
|
||||
const Json::Value& jvParams, const bool bSSL,
|
||||
boost::function<void(const Json::Value& jvInput)> callbackFuncP = 0);
|
||||
FUNCTION_TYPE<void(const Json::Value& jvInput)> callbackFuncP = 0);
|
||||
#endif
|
||||
|
||||
// vim:ts=4
|
||||
|
||||
@@ -209,6 +209,12 @@ void ConnectionPool::policyEnforce()
|
||||
// Enforce policies.
|
||||
policyLowWater();
|
||||
|
||||
if (((++mPhase) % 12) == 0)
|
||||
{
|
||||
cLog(lsTRACE) << "Making configured connections";
|
||||
makeConfigured();
|
||||
}
|
||||
|
||||
// Schedule next enforcement.
|
||||
mPolicyTimer.expires_at(boost::posix_time::second_clock::universal_time()+boost::posix_time::seconds(POLICY_INTERVAL_SECONDS));
|
||||
mPolicyTimer.async_wait(boost::bind(&ConnectionPool::policyHandler, this, _1));
|
||||
@@ -313,11 +319,11 @@ Peer::pointer ConnectionPool::peerConnect(const std::string& strIp, int iPort)
|
||||
if (ppResult)
|
||||
{
|
||||
ppResult->connect(strIp, iPort);
|
||||
//cLog(lsINFO) << "Pool: Connecting: " << ADDRESS_SHARED(ppResult) << ": " << strIp << " " << iPort;
|
||||
cLog(lsTRACE) << "Pool: Connecting: " << ADDRESS_SHARED(ppResult) << ": " << strIp << " " << iPort;
|
||||
}
|
||||
else
|
||||
{
|
||||
//cLog(lsINFO) << "Pool: Already connected: " << strIp << " " << iPort;
|
||||
cLog(lsTRACE) << "Pool: Already connected: " << strIp << " " << iPort;
|
||||
}
|
||||
|
||||
return ppResult;
|
||||
@@ -623,6 +629,20 @@ void ConnectionPool::scanHandler(const boost::system::error_code& ecResult)
|
||||
}
|
||||
}
|
||||
|
||||
void ConnectionPool::makeConfigured()
|
||||
{
|
||||
if (theConfig.RUN_STANDALONE)
|
||||
return;
|
||||
|
||||
BOOST_FOREACH(const std::string& strPeer, theConfig.IPS)
|
||||
{
|
||||
std::string strIP;
|
||||
int iPort;
|
||||
if (parseIpPort(strPeer, strIP, iPort))
|
||||
peerConnect(strIP, iPort);
|
||||
}
|
||||
}
|
||||
|
||||
// Scan ips as per db entries.
|
||||
void ConnectionPool::scanRefresh()
|
||||
{
|
||||
|
||||
@@ -18,6 +18,7 @@ class ConnectionPool
|
||||
private:
|
||||
boost::recursive_mutex mPeerLock;
|
||||
uint64 mLastPeer;
|
||||
int mPhase;
|
||||
|
||||
typedef std::pair<RippleAddress, Peer::pointer> naPeer;
|
||||
typedef std::pair<ipPort, Peer::pointer> pipPeer;
|
||||
@@ -59,7 +60,7 @@ private:
|
||||
|
||||
public:
|
||||
ConnectionPool(boost::asio::io_service& io_service) :
|
||||
mLastPeer(0), mScanTimer(io_service), mPolicyTimer(io_service)
|
||||
mLastPeer(0), mPhase(0), mScanTimer(io_service), mPolicyTimer(io_service)
|
||||
{ ; }
|
||||
|
||||
// Begin enforcing connection policy.
|
||||
@@ -114,6 +115,8 @@ public:
|
||||
void policyLowWater();
|
||||
void policyEnforce();
|
||||
|
||||
// configured connections
|
||||
void makeConfigured();
|
||||
};
|
||||
|
||||
extern void splitIpPort(const std::string& strIpPort, std::string& strIp, int& iPort);
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
#include "utils.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <boost/bind.hpp>
|
||||
#include <boost/date_time/posix_time/posix_time.hpp>
|
||||
#include <boost/regex.hpp>
|
||||
#include <boost/smart_ptr/shared_ptr.hpp>
|
||||
@@ -52,9 +51,9 @@ void HttpsClient::makeGet(const std::string& strPath, boost::asio::streambuf& sb
|
||||
void HttpsClient::httpsRequest(
|
||||
bool bSSL,
|
||||
std::deque<std::string> deqSites,
|
||||
boost::function<void(boost::asio::streambuf& sb, const std::string& strHost)> build,
|
||||
FUNCTION_TYPE<void(boost::asio::streambuf& sb, const std::string& strHost)> build,
|
||||
boost::posix_time::time_duration timeout,
|
||||
boost::function<bool(const boost::system::error_code& ecResult, int iStatus, const std::string& strData)> complete)
|
||||
FUNCTION_TYPE<bool(const boost::system::error_code& ecResult, int iStatus, const std::string& strData)> complete)
|
||||
{
|
||||
mSSL = bSSL;
|
||||
mDeqSites = deqSites;
|
||||
@@ -70,7 +69,7 @@ void HttpsClient::httpsGet(
|
||||
std::deque<std::string> deqSites,
|
||||
const std::string& strPath,
|
||||
boost::posix_time::time_duration timeout,
|
||||
boost::function<bool(const boost::system::error_code& ecResult, int iStatus, const std::string& strData)> complete) {
|
||||
FUNCTION_TYPE<bool(const boost::system::error_code& ecResult, int iStatus, const std::string& strData)> complete) {
|
||||
|
||||
mComplete = complete;
|
||||
mTimeout = timeout;
|
||||
@@ -78,7 +77,7 @@ void HttpsClient::httpsGet(
|
||||
httpsRequest(
|
||||
bSSL,
|
||||
deqSites,
|
||||
boost::bind(&HttpsClient::makeGet, shared_from_this(), strPath, _1, _2),
|
||||
BIND_TYPE(&HttpsClient::makeGet, shared_from_this(), strPath, P_1, P_2),
|
||||
timeout,
|
||||
complete);
|
||||
}
|
||||
@@ -403,7 +402,7 @@ void HttpsClient::httpsGet(
|
||||
const std::string& strPath,
|
||||
std::size_t responseMax,
|
||||
boost::posix_time::time_duration timeout,
|
||||
boost::function<bool(const boost::system::error_code& ecResult, int iStatus, const std::string& strData)> complete) {
|
||||
FUNCTION_TYPE<bool(const boost::system::error_code& ecResult, int iStatus, const std::string& strData)> complete) {
|
||||
|
||||
boost::shared_ptr<HttpsClient> client(new HttpsClient(io_service, port, responseMax));
|
||||
|
||||
@@ -418,7 +417,7 @@ void HttpsClient::httpsGet(
|
||||
const std::string& strPath,
|
||||
std::size_t responseMax,
|
||||
boost::posix_time::time_duration timeout,
|
||||
boost::function<bool(const boost::system::error_code& ecResult, int iStatus, const std::string& strData)> complete) {
|
||||
FUNCTION_TYPE<bool(const boost::system::error_code& ecResult, int iStatus, const std::string& strData)> complete) {
|
||||
|
||||
std::deque<std::string> deqSites(1, strSite);
|
||||
|
||||
@@ -432,10 +431,10 @@ void HttpsClient::httpsRequest(
|
||||
boost::asio::io_service& io_service,
|
||||
std::string strSite,
|
||||
const unsigned short port,
|
||||
boost::function<void(boost::asio::streambuf& sb, const std::string& strHost)> setRequest,
|
||||
FUNCTION_TYPE<void(boost::asio::streambuf& sb, const std::string& strHost)> setRequest,
|
||||
std::size_t responseMax,
|
||||
boost::posix_time::time_duration timeout,
|
||||
boost::function<bool(const boost::system::error_code& ecResult, int iStatus, const std::string& strData)> complete) {
|
||||
FUNCTION_TYPE<bool(const boost::system::error_code& ecResult, int iStatus, const std::string& strData)> complete) {
|
||||
|
||||
std::deque<std::string> deqSites(1, strSite);
|
||||
|
||||
|
||||
@@ -8,10 +8,10 @@
|
||||
#include <boost/asio/ssl.hpp>
|
||||
#include <boost/date_time/posix_time/posix_time_types.hpp>
|
||||
#include <boost/enable_shared_from_this.hpp>
|
||||
#include <boost/function.hpp>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
|
||||
#include "AutoSocket.h"
|
||||
#include "utils.h"
|
||||
|
||||
//
|
||||
// Async https client.
|
||||
@@ -33,8 +33,8 @@ private:
|
||||
const unsigned short mPort;
|
||||
int mResponseMax;
|
||||
int mStatus;
|
||||
boost::function<void(boost::asio::streambuf& sb, const std::string& strHost)> mBuild;
|
||||
boost::function<bool(const boost::system::error_code& ecResult, int iStatus, const std::string& strData)> mComplete;
|
||||
FUNCTION_TYPE<void(boost::asio::streambuf& sb, const std::string& strHost)> mBuild;
|
||||
FUNCTION_TYPE<bool(const boost::system::error_code& ecResult, int iStatus, const std::string& strData)> mComplete;
|
||||
|
||||
boost::asio::deadline_timer mDeadline;
|
||||
|
||||
@@ -76,16 +76,16 @@ public:
|
||||
void httpsRequest(
|
||||
bool bSSL,
|
||||
std::deque<std::string> deqSites,
|
||||
boost::function<void(boost::asio::streambuf& sb, const std::string& strHost)> build,
|
||||
FUNCTION_TYPE<void(boost::asio::streambuf& sb, const std::string& strHost)> build,
|
||||
boost::posix_time::time_duration timeout,
|
||||
boost::function<bool(const boost::system::error_code& ecResult, int iStatus, const std::string& strData)> complete);
|
||||
FUNCTION_TYPE<bool(const boost::system::error_code& ecResult, int iStatus, const std::string& strData)> complete);
|
||||
|
||||
void httpsGet(
|
||||
bool bSSL,
|
||||
std::deque<std::string> deqSites,
|
||||
const std::string& strPath,
|
||||
boost::posix_time::time_duration timeout,
|
||||
boost::function<bool(const boost::system::error_code& ecResult, int iStatus, const std::string& strData)> complete);
|
||||
FUNCTION_TYPE<bool(const boost::system::error_code& ecResult, int iStatus, const std::string& strData)> complete);
|
||||
|
||||
static void httpsGet(
|
||||
bool bSSL,
|
||||
@@ -95,7 +95,7 @@ public:
|
||||
const std::string& strPath,
|
||||
std::size_t responseMax,
|
||||
boost::posix_time::time_duration timeout,
|
||||
boost::function<bool(const boost::system::error_code& ecResult, int iStatus, const std::string& strData)> complete);
|
||||
FUNCTION_TYPE<bool(const boost::system::error_code& ecResult, int iStatus, const std::string& strData)> complete);
|
||||
|
||||
static void httpsGet(
|
||||
bool bSSL,
|
||||
@@ -105,17 +105,17 @@ public:
|
||||
const std::string& strPath,
|
||||
std::size_t responseMax,
|
||||
boost::posix_time::time_duration timeout,
|
||||
boost::function<bool(const boost::system::error_code& ecResult, int iStatus, const std::string& strData)> complete);
|
||||
FUNCTION_TYPE<bool(const boost::system::error_code& ecResult, int iStatus, const std::string& strData)> complete);
|
||||
|
||||
static void httpsRequest(
|
||||
bool bSSL,
|
||||
boost::asio::io_service& io_service,
|
||||
std::string strSite,
|
||||
const unsigned short port,
|
||||
boost::function<void(boost::asio::streambuf& sb, const std::string& strHost)> build,
|
||||
FUNCTION_TYPE<void(boost::asio::streambuf& sb, const std::string& strHost)> build,
|
||||
std::size_t responseMax,
|
||||
boost::posix_time::time_duration timeout,
|
||||
boost::function<bool(const boost::system::error_code& ecResult, int iStatus, const std::string& strData)> complete);
|
||||
FUNCTION_TYPE<bool(const boost::system::error_code& ecResult, int iStatus, const std::string& strData)> complete);
|
||||
};
|
||||
#endif
|
||||
// vim:ts=4
|
||||
|
||||
@@ -421,7 +421,13 @@ void Ledger::saveAcceptedLedger(Job&, bool fromConsensus)
|
||||
assert(false);
|
||||
}
|
||||
|
||||
assert (getAccountHash() == mAccountStateMap->getHash());
|
||||
if (getAccountHash() != mAccountStateMap->getHash())
|
||||
{
|
||||
cLog(lsFATAL) << "sAL: " << getAccountHash() << " != " << mAccountStateMap->getHash();
|
||||
cLog(lsFATAL) << "saveAcceptedLedger: seq=" << mLedgerSeq << ", fromcons=" << fromConsensus;
|
||||
assert(false);
|
||||
}
|
||||
|
||||
assert (getTransHash() == mTransactionMap->getHash());
|
||||
|
||||
// Save the ledger header in the hashed object store
|
||||
@@ -1608,6 +1614,32 @@ uint64 Ledger::scaleFeeLoad(uint64 fee)
|
||||
return theApp->getFeeTrack().scaleFeeLoad(fee, mBaseFee, mReferenceFeeUnits);
|
||||
}
|
||||
|
||||
std::vector<uint256> Ledger::getNeededTransactionHashes(int max)
|
||||
{
|
||||
std::vector<uint256> ret;
|
||||
if (mTransHash.isNonZero())
|
||||
{
|
||||
if (mTransactionMap->getHash().isZero())
|
||||
ret.push_back(mTransHash);
|
||||
else
|
||||
ret = mTransactionMap->getNeededHashes(max);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::vector<uint256> Ledger::getNeededAccountStateHashes(int max)
|
||||
{
|
||||
std::vector<uint256> ret;
|
||||
if (mAccountHash.isNonZero())
|
||||
{
|
||||
if (mAccountStateMap->getHash().isZero())
|
||||
ret.push_back(mAccountHash);
|
||||
else
|
||||
ret = mAccountStateMap->getNeededHashes(max);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE(quality)
|
||||
|
||||
BOOST_AUTO_TEST_CASE( getquality )
|
||||
|
||||
@@ -222,6 +222,9 @@ public:
|
||||
static uint256 getLedgerFeatureIndex();
|
||||
static uint256 getLedgerFeeIndex();
|
||||
|
||||
std::vector<uint256> getNeededTransactionHashes(int max);
|
||||
std::vector<uint256> getNeededAccountStateHashes(int max);
|
||||
|
||||
// index calculation functions
|
||||
static uint256 getAccountRootIndex(const uint160& uAccountID);
|
||||
|
||||
|
||||
@@ -73,13 +73,21 @@ void PeerSet::TimerEntry(boost::weak_ptr<PeerSet> wptr, const boost::system::err
|
||||
return;
|
||||
boost::shared_ptr<PeerSet> ptr = wptr.lock();
|
||||
if (ptr)
|
||||
theApp->getJobQueue().addJob(jtLEDGER_DATA, "timerEntry",
|
||||
{
|
||||
int jc = theApp->getJobQueue().getJobCountTotal(jtLEDGER_DATA);
|
||||
if (jc > 4)
|
||||
{
|
||||
cLog(lsDEBUG) << "Deferring PeerSet timer due to load";
|
||||
ptr->setTimer();
|
||||
}
|
||||
else theApp->getJobQueue().addJob(jtLEDGER_DATA, "timerEntry",
|
||||
BIND_TYPE(&PeerSet::TimerJobEntry, P_1, ptr));
|
||||
}
|
||||
}
|
||||
|
||||
void PeerSet::TimerJobEntry(Job&, boost::shared_ptr<PeerSet> ptr)
|
||||
{
|
||||
ptr->invokeOnTimer();
|
||||
ptr->invokeOnTimer();
|
||||
}
|
||||
|
||||
bool PeerSet::isActive()
|
||||
@@ -105,14 +113,9 @@ bool LedgerAcquire::tryLocal()
|
||||
{
|
||||
HashedObject::pointer node = theApp->getHashedObjectStore().retrieve(mHash);
|
||||
if (!node)
|
||||
{
|
||||
mLedger = theApp->getLedgerMaster().getLedgerByHash(mHash);
|
||||
if (!mLedger)
|
||||
return false;
|
||||
}
|
||||
else
|
||||
mLedger = boost::make_shared<Ledger>(strCopy(node->getData()), true);
|
||||
return false;
|
||||
|
||||
mLedger = boost::make_shared<Ledger>(strCopy(node->getData()), true);
|
||||
if (mLedger->getHash() != mHash)
|
||||
{ // We know for a fact the ledger can never be acquired
|
||||
cLog(lsWARNING) << mHash << " cannot be a ledger";
|
||||
@@ -136,7 +139,7 @@ bool LedgerAcquire::tryLocal()
|
||||
{
|
||||
mLedger->peekTransactionMap()->fetchRoot(mLedger->getTransHash());
|
||||
cLog(lsDEBUG) << "Got root txn map locally";
|
||||
std::vector<uint256> h = mLedger->peekTransactionMap()->getNeededHashes(1);
|
||||
std::vector<uint256> h = mLedger->getNeededTransactionHashes(1);
|
||||
if (h.empty())
|
||||
{
|
||||
cLog(lsDEBUG) << "Had full txn map locally";
|
||||
@@ -152,14 +155,17 @@ bool LedgerAcquire::tryLocal()
|
||||
if (!mHaveState)
|
||||
{
|
||||
if (mLedger->getAccountHash().isZero())
|
||||
{
|
||||
cLog(lsFATAL) << "We are acquiring a ledger with a zero account hash";
|
||||
mHaveState = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
mLedger->peekAccountStateMap()->fetchRoot(mLedger->getAccountHash());
|
||||
cLog(lsDEBUG) << "Got root AS map locally";
|
||||
std::vector<uint256> h = mLedger->peekAccountStateMap()->getNeededHashes(1);
|
||||
std::vector<uint256> h = mLedger->getNeededAccountStateHashes(1);
|
||||
if (h.empty())
|
||||
{
|
||||
cLog(lsDEBUG) << "Had full AS map locally";
|
||||
@@ -270,6 +276,7 @@ void LedgerAcquire::done()
|
||||
else
|
||||
theApp->getMasterLedgerAcquire().logFailure(mHash);
|
||||
|
||||
// FIXME: We hold the PeerSet lock
|
||||
for (unsigned int i = 0; i < triggers.size(); ++i)
|
||||
triggers[i](shared_from_this());
|
||||
}
|
||||
@@ -591,7 +598,7 @@ bool LedgerAcquire::takeBase(const std::string& data) // data must not have hash
|
||||
cLog(lsTRACE) << "got base acquiring ledger " << mHash;
|
||||
#endif
|
||||
boost::recursive_mutex::scoped_lock sl(mLock);
|
||||
if (mHaveBase)
|
||||
if (mComplete || mFailed || mHaveBase)
|
||||
return true;
|
||||
mLedger = boost::make_shared<Ledger>(data, false);
|
||||
if (mLedger->getHash() != mHash)
|
||||
@@ -626,7 +633,7 @@ bool LedgerAcquire::takeTxNode(const std::list<SHAMapNode>& nodeIDs,
|
||||
boost::recursive_mutex::scoped_lock sl(mLock);
|
||||
if (!mHaveBase)
|
||||
return false;
|
||||
if (mHaveTransactions)
|
||||
if (mHaveTransactions || mFailed)
|
||||
return true;
|
||||
|
||||
std::list<SHAMapNode>::const_iterator nodeIDit = nodeIDs.begin();
|
||||
@@ -673,7 +680,7 @@ bool LedgerAcquire::takeAsNode(const std::list<SHAMapNode>& nodeIDs,
|
||||
cLog(lsWARNING) << "Don't have ledger base";
|
||||
return false;
|
||||
}
|
||||
if (mHaveState)
|
||||
if (mHaveState || mFailed)
|
||||
return true;
|
||||
|
||||
std::list<SHAMapNode>::const_iterator nodeIDit = nodeIDs.begin();
|
||||
@@ -714,6 +721,8 @@ bool LedgerAcquire::takeAsNode(const std::list<SHAMapNode>& nodeIDs,
|
||||
bool LedgerAcquire::takeAsRootNode(const std::vector<unsigned char>& data, SMAddNode& san)
|
||||
{
|
||||
boost::recursive_mutex::scoped_lock sl(mLock);
|
||||
if (mFailed || mHaveState)
|
||||
return true;
|
||||
if (!mHaveBase)
|
||||
return false;
|
||||
AccountStateSF tFilter(mLedger->getLedgerSeq());
|
||||
@@ -724,6 +733,8 @@ bool LedgerAcquire::takeAsRootNode(const std::vector<unsigned char>& data, SMAdd
|
||||
bool LedgerAcquire::takeTxRootNode(const std::vector<unsigned char>& data, SMAddNode& san)
|
||||
{
|
||||
boost::recursive_mutex::scoped_lock sl(mLock);
|
||||
if (mFailed || mHaveState)
|
||||
return true;
|
||||
if (!mHaveBase)
|
||||
return false;
|
||||
TransactionStateSF tFilter(mLedger->getLedgerSeq());
|
||||
@@ -775,13 +786,13 @@ std::vector<LedgerAcquire::neededHash_t> LedgerAcquire::getNeededHashes()
|
||||
}
|
||||
if (!mHaveState)
|
||||
{
|
||||
std::vector<uint256> v = mLedger->peekAccountStateMap()->getNeededHashes(16);
|
||||
std::vector<uint256> v = mLedger->getNeededAccountStateHashes(16);
|
||||
BOOST_FOREACH(const uint256& h, v)
|
||||
ret.push_back(std::make_pair(ripple::TMGetObjectByHash::otSTATE_NODE, h));
|
||||
}
|
||||
if (!mHaveTransactions)
|
||||
{
|
||||
std::vector<uint256> v = mLedger->peekTransactionMap()->getNeededHashes(16);
|
||||
std::vector<uint256> v = mLedger->getNeededAccountStateHashes(16);
|
||||
BOOST_FOREACH(const uint256& h, v)
|
||||
ret.push_back(std::make_pair(ripple::TMGetObjectByHash::otTRANSACTION_NODE, h));
|
||||
}
|
||||
@@ -855,7 +866,7 @@ void LedgerAcquireMaster::gotLedgerData(Job&, boost::shared_ptr<ripple::TMLedger
|
||||
LedgerAcquire::pointer ledger = find(hash);
|
||||
if (!ledger)
|
||||
{
|
||||
cLog(lsINFO) << "Got data for ledger we're not acquiring";
|
||||
cLog(lsTRACE) << "Got data for ledger we're not acquiring";
|
||||
peer->punishPeer(LT_InvalidRequest);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ void LedgerHistory::addLedger(Ledger::pointer ledger)
|
||||
void LedgerHistory::addAcceptedLedger(Ledger::pointer ledger, bool fromConsensus)
|
||||
{
|
||||
assert(ledger && ledger->isAccepted() && ledger->isImmutable());
|
||||
assert(ledger->peekAccountStateMap()->getHash().isNonZero());
|
||||
uint256 h(ledger->getHash());
|
||||
boost::recursive_mutex::scoped_lock sl(mLedgersByHash.peekMutex());
|
||||
mLedgersByHash.canonicalize(h, ledger, true);
|
||||
|
||||
@@ -316,7 +316,7 @@ void LedgerMaster::resumeAcquiring()
|
||||
else
|
||||
{
|
||||
mCompleteLedgers.clearValue(prevMissing);
|
||||
cLog(lsWARNING) << "We have a gap at: " << prevMissing + 1;
|
||||
cLog(lsINFO) << "We have a gap at: " << prevMissing + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -353,6 +353,7 @@ void LedgerMaster::fixMismatch(Ledger::ref ledger)
|
||||
void LedgerMaster::setFullLedger(Ledger::pointer ledger)
|
||||
{ // A new ledger has been accepted as part of the trusted chain
|
||||
cLog(lsDEBUG) << "Ledger " << ledger->getLedgerSeq() << " accepted :" << ledger->getHash();
|
||||
assert(ledger->peekAccountStateMap()->getHash().isNonZero());
|
||||
|
||||
boost::recursive_mutex::scoped_lock ml(mLock);
|
||||
|
||||
|
||||
@@ -210,6 +210,7 @@ void NetworkOPs::submitTransaction(Job&, SerializedTransaction::pointer iTrans,
|
||||
}
|
||||
}
|
||||
|
||||
// FIXME: Should submit to job queue
|
||||
theApp->getIOService().post(boost::bind(&NetworkOPs::processTransaction, this,
|
||||
boost::make_shared<Transaction>(trans, false), callback));
|
||||
}
|
||||
|
||||
@@ -185,7 +185,7 @@ public:
|
||||
//
|
||||
// Transaction operations
|
||||
//
|
||||
typedef boost::function<void (Transaction::pointer, TER)> stCallback; // must complete immediately
|
||||
typedef FUNCTION_TYPE<void (Transaction::pointer, TER)> stCallback; // must complete immediately
|
||||
void submitTransaction(Job&, SerializedTransaction::pointer, stCallback callback = stCallback());
|
||||
Transaction::pointer submitTransactionSync(Transaction::ref tpTrans, bool bSubmit=true);
|
||||
|
||||
|
||||
@@ -830,7 +830,7 @@ static void checkTransaction(Job&, int flags, SerializedTransaction::pointer stx
|
||||
else
|
||||
tx = boost::make_shared<Transaction>(stx, false);
|
||||
|
||||
theApp->getIOService().post(boost::bind(&NetworkOPs::processTransaction, &theApp->getOPs(), tx));
|
||||
theApp->getOPs().processTransaction(tx);
|
||||
|
||||
#ifndef TRUST_NETWORK
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ void SHAMap::getMissingNodes(std::vector<SHAMapNode>& nodeIDs, std::vector<uint2
|
||||
stack.pop();
|
||||
|
||||
int base = rand() % 256;
|
||||
bool have_all = false;
|
||||
bool have_all = true;
|
||||
for (int ii = 0; ii < 16; ++ii)
|
||||
{ // traverse in semi-random order
|
||||
int branch = (base + ii) % 16;
|
||||
@@ -72,14 +72,17 @@ void SHAMap::getMissingNodes(std::vector<SHAMapNode>& nodeIDs, std::vector<uint2
|
||||
}
|
||||
if (!d)
|
||||
{ // we need this node
|
||||
have_all = false;
|
||||
nodeIDs.push_back(childID);
|
||||
hashes.push_back(childHash);
|
||||
if (--max <= 0)
|
||||
return;
|
||||
have_all = false;
|
||||
}
|
||||
else if (d->isInner() && !d->isFullBelow()) // we might need children of this node
|
||||
{
|
||||
have_all = false;
|
||||
stack.push(d);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (have_all)
|
||||
@@ -111,7 +114,7 @@ std::vector<uint256> SHAMap::getNeededHashes(int max)
|
||||
stack.pop();
|
||||
|
||||
int base = rand() % 256;
|
||||
bool have_all = false;
|
||||
bool have_all = true;
|
||||
for (int ii = 0; ii < 16; ++ii)
|
||||
{ // traverse in semi-random order
|
||||
int branch = (base + ii) % 16;
|
||||
@@ -124,7 +127,10 @@ std::vector<uint256> SHAMap::getNeededHashes(int max)
|
||||
SHAMapTreeNode* d = getNodePointer(childID, childHash);
|
||||
assert(d);
|
||||
if (d->isInner() && !d->isFullBelow())
|
||||
{
|
||||
have_all = false;
|
||||
stack.push(d);
|
||||
}
|
||||
}
|
||||
catch (SHAMapMissingNode&)
|
||||
{ // node is not in the map
|
||||
|
||||
@@ -885,7 +885,7 @@ void UniqueNodeList::getValidatorsUrl(const RippleAddress& naNodePublic, section
|
||||
strPath,
|
||||
NODE_FILE_BYTES_MAX,
|
||||
boost::posix_time::seconds(NODE_FETCH_SECONDS),
|
||||
boost::bind(&UniqueNodeList::responseValidators, this, strValidatorsUrl, naNodePublic, secSite, strDomain, _1, _2, _3));
|
||||
BIND_TYPE(&UniqueNodeList::responseValidators, this, strValidatorsUrl, naNodePublic, secSite, strDomain, P_1, P_2, P_3));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1063,7 +1063,7 @@ void UniqueNodeList::fetchProcess(std::string strDomain)
|
||||
NODE_FILE_PATH,
|
||||
NODE_FILE_BYTES_MAX,
|
||||
boost::posix_time::seconds(NODE_FETCH_SECONDS),
|
||||
boost::bind(&UniqueNodeList::responseFetch, this, strDomain, _1, _2, _3));
|
||||
BIND_TYPE(&UniqueNodeList::responseFetch, this, strDomain, P_1, P_2, P_3));
|
||||
}
|
||||
|
||||
void UniqueNodeList::fetchTimerHandler(const boost::system::error_code& err)
|
||||
@@ -1610,7 +1610,7 @@ void UniqueNodeList::nodeNetwork()
|
||||
theConfig.VALIDATORS_URI,
|
||||
VALIDATORS_FILE_BYTES_MAX,
|
||||
boost::posix_time::seconds(VALIDATORS_FETCH_SECONDS),
|
||||
boost::bind(&UniqueNodeList::validatorsResponse, this, _1, _2, _3));
|
||||
BIND_TYPE(&UniqueNodeList::validatorsResponse, this, P_1, P_2, P_3));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user