mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-21 11:35:53 +00:00
Rename LedgerAcquire to InboundLedger
This commit is contained in:
@@ -12,15 +12,6 @@ struct sqlite3_stmt;
|
||||
|
||||
class SqliteDatabase : public Database
|
||||
{
|
||||
sqlite3* mConnection;
|
||||
sqlite3* mAuxConnection;
|
||||
sqlite3_stmt* mCurrentStmt;
|
||||
bool mMoreRows;
|
||||
|
||||
boost::mutex walMutex;
|
||||
JobQueue* mWalQ;
|
||||
bool walRunning;
|
||||
|
||||
public:
|
||||
SqliteDatabase (const char* host);
|
||||
|
||||
@@ -67,6 +58,16 @@ public:
|
||||
|
||||
int getKBUsedDB ();
|
||||
int getKBUsedAll ();
|
||||
|
||||
private:
|
||||
sqlite3* mConnection;
|
||||
sqlite3* mAuxConnection;
|
||||
sqlite3_stmt* mCurrentStmt;
|
||||
bool mMoreRows;
|
||||
|
||||
boost::mutex walMutex;
|
||||
JobQueue* mWalQ;
|
||||
bool walRunning;
|
||||
};
|
||||
|
||||
class SqliteStatement
|
||||
|
||||
@@ -277,13 +277,13 @@ bool LedgerMaster::acquireMissingLedger (Ledger::ref origLedger, uint256 const&
|
||||
return true;
|
||||
}
|
||||
|
||||
if (theApp->getMasterLedgerAcquire ().isFailure (ledgerHash))
|
||||
if (theApp->getInboundLedgers ().isFailure (ledgerHash))
|
||||
{
|
||||
WriteLog (lsTRACE, LedgerMaster) << "Already failed to acquire " << ledgerSeq;
|
||||
return false;
|
||||
}
|
||||
|
||||
mMissingLedger = theApp->getMasterLedgerAcquire ().findCreate (ledgerHash, ledgerSeq);
|
||||
mMissingLedger = theApp->getInboundLedgers ().findCreate (ledgerHash, ledgerSeq);
|
||||
|
||||
if (mMissingLedger->isComplete ())
|
||||
{
|
||||
@@ -311,7 +311,7 @@ bool LedgerMaster::acquireMissingLedger (Ledger::ref origLedger, uint256 const&
|
||||
|
||||
int fetchMax = theConfig.getSize (siLedgerFetch);
|
||||
int timeoutCount;
|
||||
int fetchCount = theApp->getMasterLedgerAcquire ().getFetchCount (timeoutCount);
|
||||
int fetchCount = theApp->getInboundLedgers ().getFetchCount (timeoutCount);
|
||||
|
||||
if ((fetchCount < fetchMax) && theApp->getOPs ().isFull ())
|
||||
{
|
||||
@@ -326,9 +326,9 @@ bool LedgerMaster::acquireMissingLedger (Ledger::ref origLedger, uint256 const&
|
||||
BOOST_REVERSE_FOREACH (const u_pair & it, vec)
|
||||
{
|
||||
if ((fetchCount < fetchMax) && (it.first < ledgerSeq) &&
|
||||
!mCompleteLedgers.hasValue (it.first) && !theApp->getMasterLedgerAcquire ().find (it.second))
|
||||
!mCompleteLedgers.hasValue (it.first) && !theApp->getInboundLedgers ().find (it.second))
|
||||
{
|
||||
LedgerAcquire::pointer acq = theApp->getMasterLedgerAcquire ().findCreate (it.second, it.first);
|
||||
InboundLedger::pointer acq = theApp->getInboundLedgers ().findCreate (it.second, it.first);
|
||||
|
||||
if (acq && acq->isComplete ())
|
||||
{
|
||||
@@ -384,7 +384,7 @@ bool LedgerMaster::acquireMissingLedger (Ledger::ref origLedger, uint256 const&
|
||||
return true;
|
||||
}
|
||||
|
||||
void LedgerMaster::missingAcquireComplete (LedgerAcquire::pointer acq)
|
||||
void LedgerMaster::missingAcquireComplete (InboundLedger::pointer acq)
|
||||
{
|
||||
boost::recursive_mutex::scoped_lock ml (mLock);
|
||||
|
||||
@@ -418,6 +418,12 @@ bool LedgerMaster::shouldAcquire (uint32 currentLedger, uint32 ledgerHistory, ui
|
||||
|
||||
void LedgerMaster::resumeAcquiring ()
|
||||
{
|
||||
// VFALCO NOTE These returns from the middle are troubling. You might think
|
||||
// that calling a function called "resumeAcquiring" would
|
||||
// actually resume acquiring. But it doesn't always resume acquiring,
|
||||
// based on a myriad of conditions which short circuit the function
|
||||
// in ways that the caller cannot expect or predict.
|
||||
//
|
||||
if (!theApp->getOPs ().isFull ())
|
||||
return;
|
||||
|
||||
@@ -525,7 +531,7 @@ void LedgerMaster::setFullLedger (Ledger::pointer ledger)
|
||||
if (mMissingLedger && mMissingLedger->isDone ())
|
||||
{
|
||||
if (mMissingLedger->isFailed ())
|
||||
theApp->getMasterLedgerAcquire ().dropLedger (mMissingLedger->getHash ());
|
||||
theApp->getInboundLedgers ().dropLedger (mMissingLedger->getHash ());
|
||||
|
||||
mMissingLedger.reset ();
|
||||
}
|
||||
@@ -628,7 +634,7 @@ void LedgerMaster::checkAccept (uint256 const& hash, uint32 seq)
|
||||
|
||||
if (!ledger)
|
||||
{
|
||||
theApp->getMasterLedgerAcquire ().findCreate (hash, seq);
|
||||
theApp->getInboundLedgers ().findCreate (hash, seq);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -689,13 +695,13 @@ void LedgerMaster::tryPublish ()
|
||||
}
|
||||
else
|
||||
{
|
||||
if (theApp->getMasterLedgerAcquire ().isFailure (hash))
|
||||
if (theApp->getInboundLedgers ().isFailure (hash))
|
||||
{
|
||||
WriteLog (lsWARNING, LedgerMaster) << "Unable to acquire a recent validated ledger";
|
||||
}
|
||||
else
|
||||
{
|
||||
LedgerAcquire::pointer acq = theApp->getMasterLedgerAcquire ().findCreate (hash, seq);
|
||||
InboundLedger::pointer acq = theApp->getInboundLedgers ().findCreate (hash, seq);
|
||||
|
||||
if (!acq->isDone ())
|
||||
{
|
||||
|
||||
@@ -177,7 +177,7 @@ private:
|
||||
|
||||
bool acquireMissingLedger (Ledger::ref from, uint256 const& ledgerHash, uint32 ledgerSeq);
|
||||
void asyncAccept (Ledger::pointer);
|
||||
void missingAcquireComplete (LedgerAcquire::pointer);
|
||||
void missingAcquireComplete (InboundLedger::pointer);
|
||||
void pubThread ();
|
||||
void updatePaths ();
|
||||
|
||||
@@ -197,7 +197,7 @@ private:
|
||||
CanonicalTXSet mHeldTransactions;
|
||||
|
||||
RangeSet mCompleteLedgers;
|
||||
LedgerAcquire::pointer mMissingLedger;
|
||||
InboundLedger::pointer mMissingLedger;
|
||||
uint32 mMissingSeq;
|
||||
|
||||
int mMinValidations; // The minimum validations to publish a ledger
|
||||
|
||||
@@ -798,7 +798,7 @@ bool NetworkOPs::checkLastClosedLedger (const std::vector<Peer::pointer>& peerLi
|
||||
if (mAcquiringLedger)
|
||||
{
|
||||
mAcquiringLedger->abort ();
|
||||
theApp->getMasterLedgerAcquire ().dropLedger (mAcquiringLedger->getHash ());
|
||||
theApp->getInboundLedgers ().dropLedger (mAcquiringLedger->getHash ());
|
||||
mAcquiringLedger.reset ();
|
||||
}
|
||||
|
||||
@@ -819,11 +819,11 @@ bool NetworkOPs::checkLastClosedLedger (const std::vector<Peer::pointer>& peerLi
|
||||
WriteLog (lsINFO, NetworkOPs) << "Acquiring consensus ledger " << closedLedger;
|
||||
|
||||
if (!mAcquiringLedger || (mAcquiringLedger->getHash () != closedLedger))
|
||||
mAcquiringLedger = theApp->getMasterLedgerAcquire ().findCreate (closedLedger, 0);
|
||||
mAcquiringLedger = theApp->getInboundLedgers ().findCreate (closedLedger, 0);
|
||||
|
||||
if (!mAcquiringLedger || mAcquiringLedger->isFailed ())
|
||||
{
|
||||
theApp->getMasterLedgerAcquire ().dropLedger (closedLedger);
|
||||
theApp->getInboundLedgers ().dropLedger (closedLedger);
|
||||
WriteLog (lsERROR, NetworkOPs) << "Network ledger cannot be acquired";
|
||||
return true;
|
||||
}
|
||||
@@ -2270,7 +2270,7 @@ void NetworkOPs::gotFetchPack (bool progress, uint32 seq)
|
||||
mLastFetchPack = 0;
|
||||
mFetchSeq = seq; // earliest pack we have data on
|
||||
theApp->getJobQueue ().addJob (jtLEDGER_DATA, "gotFetchPack",
|
||||
boost::bind (&LedgerAcquireMaster::gotFetchPack, &theApp->getMasterLedgerAcquire (), _1));
|
||||
boost::bind (&InboundLedgers::gotFetchPack, &theApp->getInboundLedgers (), _1));
|
||||
}
|
||||
|
||||
void NetworkOPs::missingNodeInLedger (uint32 seq)
|
||||
@@ -2279,7 +2279,7 @@ void NetworkOPs::missingNodeInLedger (uint32 seq)
|
||||
uint256 hash = theApp->getLedgerMaster ().getHashBySeq (seq);
|
||||
|
||||
if (hash.isNonZero ())
|
||||
theApp->getMasterLedgerAcquire ().findCreate (hash, seq);
|
||||
theApp->getInboundLedgers ().findCreate (hash, seq);
|
||||
}
|
||||
|
||||
// vim:ts=4
|
||||
|
||||
@@ -391,7 +391,7 @@ private:
|
||||
std::list<LedgerProposal::pointer> > mStoredProposals;
|
||||
|
||||
LedgerMaster* mLedgerMaster;
|
||||
LedgerAcquire::pointer mAcquiringLedger;
|
||||
InboundLedger::pointer mAcquiringLedger;
|
||||
|
||||
int mCloseTimeOffset;
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// VFALCO TODO Rename the protobuf namespace from ripple to 'wire' or something
|
||||
//
|
||||
package ripple;
|
||||
|
||||
enum MessageType
|
||||
|
||||
@@ -43,9 +43,9 @@ public:
|
||||
{
|
||||
return mLedgerMaster;
|
||||
}
|
||||
LedgerAcquireMaster& getMasterLedgerAcquire ()
|
||||
InboundLedgers& getInboundLedgers ()
|
||||
{
|
||||
return mMasterLedgerAcquire;
|
||||
return m_inboundLedgers;
|
||||
}
|
||||
TransactionMaster& getMasterTransaction ()
|
||||
{
|
||||
@@ -192,7 +192,7 @@ private:
|
||||
|
||||
LocalCredentials mLocalCredentials;
|
||||
LedgerMaster mLedgerMaster;
|
||||
LedgerAcquireMaster mMasterLedgerAcquire;
|
||||
InboundLedgers m_inboundLedgers;
|
||||
TransactionMaster mMasterTransaction;
|
||||
NetworkOPs mNetOps;
|
||||
NodeCache mTempNodeCache;
|
||||
@@ -215,10 +215,17 @@ private:
|
||||
beast::ScopedPointer <IPeers> mPeers;
|
||||
// VFALCO End Clean stuff
|
||||
|
||||
DatabaseCon* mRpcDB, *mTxnDB, *mLedgerDB, *mWalletDB, *mNetNodeDB, *mPathFindDB, *mHashNodeDB;
|
||||
DatabaseCon* mRpcDB;
|
||||
DatabaseCon* mTxnDB;
|
||||
DatabaseCon* mLedgerDB;
|
||||
DatabaseCon* mWalletDB;
|
||||
DatabaseCon* mNetNodeDB;
|
||||
DatabaseCon* mPathFindDB;
|
||||
DatabaseCon* mHashNodeDB;
|
||||
|
||||
leveldb::DB* mHashNodeLDB;
|
||||
leveldb::DB* mEphemeralLDB;
|
||||
// VFALCO TODO Wrap this in an interface
|
||||
leveldb::DB* mHashNodeLDB;
|
||||
leveldb::DB* mEphemeralLDB;
|
||||
|
||||
PeerDoor* mPeerDoor;
|
||||
RPCDoor* mRPCDoor;
|
||||
@@ -227,7 +234,7 @@ private:
|
||||
|
||||
boost::asio::deadline_timer mSweepTimer;
|
||||
|
||||
std::map<std::string, Peer::pointer> mPeerMap;
|
||||
std::map <std::string, Peer::pointer> mPeerMap;
|
||||
boost::recursive_mutex mPeerMapLock;
|
||||
|
||||
volatile bool mShutdown;
|
||||
@@ -638,7 +645,7 @@ void Application::sweep ()
|
||||
mLedgerMaster.sweep ();
|
||||
mTempNodeCache.sweep ();
|
||||
mValidations->sweep ();
|
||||
getMasterLedgerAcquire ().sweep ();
|
||||
getInboundLedgers ().sweep ();
|
||||
mSLECache.sweep ();
|
||||
AcceptedLedger::sweep (); // VFALCO NOTE AcceptedLedger is/has a singleton?
|
||||
SHAMap::sweep (); // VFALCO NOTE SHAMap is/has a singleton?
|
||||
|
||||
@@ -28,7 +28,7 @@ class IValidations;
|
||||
|
||||
class HashedObjectStore;
|
||||
class JobQueue;
|
||||
class LedgerAcquireMaster;
|
||||
class InboundLedgers;
|
||||
class LedgerMaster;
|
||||
class LoadManager;
|
||||
class NetworkOPs;
|
||||
@@ -81,7 +81,7 @@ public:
|
||||
|
||||
virtual HashedObjectStore& getHashedObjectStore () = 0;
|
||||
virtual JobQueue& getJobQueue () = 0;
|
||||
virtual LedgerAcquireMaster& getMasterLedgerAcquire () = 0;
|
||||
virtual InboundLedgers& getInboundLedgers () = 0;
|
||||
virtual LedgerMaster& getLedgerMaster () = 0;
|
||||
virtual LoadManager& getLoadManager () = 0;
|
||||
virtual NetworkOPs& getOPs () = 0;
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
SETUP_LOG (LedgerAcquire)
|
||||
SETUP_LOG (InboundLedger)
|
||||
|
||||
DECLARE_INSTANCE (LedgerAcquire);
|
||||
DECLARE_INSTANCE (InboundLedger);
|
||||
|
||||
// VFALCO TODO replace macros
|
||||
#define LA_DEBUG
|
||||
@@ -15,7 +15,7 @@ DECLARE_INSTANCE (LedgerAcquire);
|
||||
#define LEDGER_TIMEOUT_AGGRESSIVE 6 // how many timeouts before we get aggressive
|
||||
#define TRUST_NETWORK
|
||||
|
||||
LedgerAcquire::LedgerAcquire (uint256 const& hash, uint32 seq)
|
||||
InboundLedger::InboundLedger (uint256 const& hash, uint32 seq)
|
||||
: PeerSet (hash, LEDGER_ACQUIRE_TIMEOUT)
|
||||
, mHaveBase (false)
|
||||
, mHaveState (false)
|
||||
@@ -28,12 +28,12 @@ LedgerAcquire::LedgerAcquire (uint256 const& hash, uint32 seq)
|
||||
, mSeq (seq)
|
||||
{
|
||||
#ifdef LA_DEBUG
|
||||
WriteLog (lsTRACE, LedgerAcquire) << "Acquiring ledger " << mHash;
|
||||
WriteLog (lsTRACE, InboundLedger) << "Acquiring ledger " << mHash;
|
||||
#endif
|
||||
tryLocal ();
|
||||
}
|
||||
|
||||
void LedgerAcquire::checkLocal ()
|
||||
void InboundLedger::checkLocal ()
|
||||
{
|
||||
boost::recursive_mutex::scoped_lock sl (mLock);
|
||||
|
||||
@@ -44,7 +44,7 @@ void LedgerAcquire::checkLocal ()
|
||||
done ();
|
||||
}
|
||||
|
||||
bool LedgerAcquire::tryLocal ()
|
||||
bool InboundLedger::tryLocal ()
|
||||
{
|
||||
// return value: true = no more work to do
|
||||
|
||||
@@ -60,7 +60,7 @@ bool LedgerAcquire::tryLocal ()
|
||||
if (!theApp->getOPs ().getFetchPack (mHash, data))
|
||||
return false;
|
||||
|
||||
WriteLog (lsTRACE, LedgerAcquire) << "Ledger base found in fetch pack";
|
||||
WriteLog (lsTRACE, InboundLedger) << "Ledger base found in fetch pack";
|
||||
mLedger = boost::make_shared<Ledger> (data, true);
|
||||
theApp->getHashedObjectStore ().store (hotLEDGER, mLedger->getLedgerSeq (), data, mHash);
|
||||
}
|
||||
@@ -72,7 +72,7 @@ bool LedgerAcquire::tryLocal ()
|
||||
if (mLedger->getHash () != mHash)
|
||||
{
|
||||
// We know for a fact the ledger can never be acquired
|
||||
WriteLog (lsWARNING, LedgerAcquire) << mHash << " cannot be a ledger";
|
||||
WriteLog (lsWARNING, InboundLedger) << mHash << " cannot be a ledger";
|
||||
mFailed = true;
|
||||
return true;
|
||||
}
|
||||
@@ -84,7 +84,7 @@ bool LedgerAcquire::tryLocal ()
|
||||
{
|
||||
if (mLedger->getTransHash ().isZero ())
|
||||
{
|
||||
WriteLog (lsTRACE, LedgerAcquire) << "No TXNs to fetch";
|
||||
WriteLog (lsTRACE, InboundLedger) << "No TXNs to fetch";
|
||||
mHaveTransactions = true;
|
||||
}
|
||||
else
|
||||
@@ -93,12 +93,12 @@ bool LedgerAcquire::tryLocal ()
|
||||
|
||||
if (mLedger->peekTransactionMap ()->fetchRoot (mLedger->getTransHash (), &filter))
|
||||
{
|
||||
WriteLog (lsTRACE, LedgerAcquire) << "Got root txn map locally";
|
||||
WriteLog (lsTRACE, InboundLedger) << "Got root txn map locally";
|
||||
std::vector<uint256> h = mLedger->getNeededTransactionHashes (1, &filter);
|
||||
|
||||
if (h.empty ())
|
||||
{
|
||||
WriteLog (lsTRACE, LedgerAcquire) << "Had full txn map locally";
|
||||
WriteLog (lsTRACE, InboundLedger) << "Had full txn map locally";
|
||||
mHaveTransactions = true;
|
||||
}
|
||||
}
|
||||
@@ -109,7 +109,7 @@ bool LedgerAcquire::tryLocal ()
|
||||
{
|
||||
if (mLedger->getAccountHash ().isZero ())
|
||||
{
|
||||
WriteLog (lsFATAL, LedgerAcquire) << "We are acquiring a ledger with a zero account hash";
|
||||
WriteLog (lsFATAL, InboundLedger) << "We are acquiring a ledger with a zero account hash";
|
||||
mHaveState = true;
|
||||
}
|
||||
else
|
||||
@@ -118,12 +118,12 @@ bool LedgerAcquire::tryLocal ()
|
||||
|
||||
if (mLedger->peekAccountStateMap ()->fetchRoot (mLedger->getAccountHash (), &filter))
|
||||
{
|
||||
WriteLog (lsTRACE, LedgerAcquire) << "Got root AS map locally";
|
||||
WriteLog (lsTRACE, InboundLedger) << "Got root AS map locally";
|
||||
std::vector<uint256> h = mLedger->getNeededAccountStateHashes (1, &filter);
|
||||
|
||||
if (h.empty ())
|
||||
{
|
||||
WriteLog (lsTRACE, LedgerAcquire) << "Had full AS map locally";
|
||||
WriteLog (lsTRACE, InboundLedger) << "Had full AS map locally";
|
||||
mHaveState = true;
|
||||
}
|
||||
}
|
||||
@@ -132,7 +132,7 @@ bool LedgerAcquire::tryLocal ()
|
||||
|
||||
if (mHaveTransactions && mHaveState)
|
||||
{
|
||||
WriteLog (lsDEBUG, LedgerAcquire) << "Had everything locally";
|
||||
WriteLog (lsDEBUG, InboundLedger) << "Had everything locally";
|
||||
mComplete = true;
|
||||
mLedger->setClosed ();
|
||||
mLedger->setImmutable ();
|
||||
@@ -141,14 +141,14 @@ bool LedgerAcquire::tryLocal ()
|
||||
return mComplete;
|
||||
}
|
||||
|
||||
void LedgerAcquire::onTimer (bool progress)
|
||||
void InboundLedger::onTimer (bool progress)
|
||||
{
|
||||
mRecentTXNodes.clear ();
|
||||
mRecentASNodes.clear ();
|
||||
|
||||
if (getTimeouts () > LEDGER_TIMEOUT_COUNT)
|
||||
{
|
||||
WriteLog (lsWARNING, LedgerAcquire) << "Too many timeouts( " << getTimeouts () << ") for ledger " << mHash;
|
||||
WriteLog (lsWARNING, InboundLedger) << "Too many timeouts( " << getTimeouts () << ") for ledger " << mHash;
|
||||
setFailed ();
|
||||
done ();
|
||||
return;
|
||||
@@ -159,7 +159,7 @@ void LedgerAcquire::onTimer (bool progress)
|
||||
mAggressive = true;
|
||||
mByHash = true;
|
||||
int pc = getPeerCount ();
|
||||
WriteLog (lsDEBUG, LedgerAcquire) << "No progress(" << pc << ") for ledger " << pc << mHash;
|
||||
WriteLog (lsDEBUG, InboundLedger) << "No progress(" << pc << ") for ledger " << pc << mHash;
|
||||
|
||||
if (pc == 0)
|
||||
addPeers ();
|
||||
@@ -168,20 +168,20 @@ void LedgerAcquire::onTimer (bool progress)
|
||||
}
|
||||
}
|
||||
|
||||
void LedgerAcquire::awaitData ()
|
||||
void InboundLedger::awaitData ()
|
||||
{
|
||||
boost::recursive_mutex::scoped_lock sl (mLock);
|
||||
++mWaitCount;
|
||||
}
|
||||
|
||||
void LedgerAcquire::noAwaitData ()
|
||||
void InboundLedger::noAwaitData ()
|
||||
{
|
||||
boost::recursive_mutex::scoped_lock sl (mLock);
|
||||
|
||||
if (mWaitCount > 0 ) --mWaitCount;
|
||||
}
|
||||
|
||||
void LedgerAcquire::addPeers ()
|
||||
void InboundLedger::addPeers ()
|
||||
{
|
||||
std::vector<Peer::pointer> peerList = theApp->getPeers ().getPeerVector ();
|
||||
|
||||
@@ -213,21 +213,21 @@ void LedgerAcquire::addPeers ()
|
||||
peerHas (peerList[ (i + firstPeer) % vSize]);
|
||||
}
|
||||
|
||||
boost::weak_ptr<PeerSet> LedgerAcquire::pmDowncast ()
|
||||
boost::weak_ptr<PeerSet> InboundLedger::pmDowncast ()
|
||||
{
|
||||
return boost::dynamic_pointer_cast<PeerSet> (shared_from_this ());
|
||||
}
|
||||
|
||||
static void LADispatch (
|
||||
Job& job,
|
||||
LedgerAcquire::pointer la,
|
||||
std::vector< FUNCTION_TYPE<void (LedgerAcquire::pointer)> > trig)
|
||||
InboundLedger::pointer la,
|
||||
std::vector< FUNCTION_TYPE<void (InboundLedger::pointer)> > trig)
|
||||
{
|
||||
for (unsigned int i = 0; i < trig.size (); ++i)
|
||||
trig[i] (la);
|
||||
}
|
||||
|
||||
void LedgerAcquire::done ()
|
||||
void InboundLedger::done ()
|
||||
{
|
||||
if (mSignaled)
|
||||
return;
|
||||
@@ -236,12 +236,12 @@ void LedgerAcquire::done ()
|
||||
touch ();
|
||||
|
||||
#ifdef LA_DEBUG
|
||||
WriteLog (lsTRACE, LedgerAcquire) << "Done acquiring ledger " << mHash;
|
||||
WriteLog (lsTRACE, InboundLedger) << "Done acquiring ledger " << mHash;
|
||||
#endif
|
||||
|
||||
assert (isComplete () || isFailed ());
|
||||
|
||||
std::vector< FUNCTION_TYPE<void (LedgerAcquire::pointer)> > triggers;
|
||||
std::vector< FUNCTION_TYPE<void (InboundLedger::pointer)> > triggers;
|
||||
{
|
||||
boost::recursive_mutex::scoped_lock sl (mLock);
|
||||
triggers.swap (mOnComplete);
|
||||
@@ -258,14 +258,14 @@ void LedgerAcquire::done ()
|
||||
theApp->getLedgerMaster ().storeLedger (mLedger);
|
||||
}
|
||||
else
|
||||
theApp->getMasterLedgerAcquire ().logFailure (mHash);
|
||||
theApp->getInboundLedgers ().logFailure (mHash);
|
||||
|
||||
if (!triggers.empty ()) // We hold the PeerSet lock, so must dispatch
|
||||
theApp->getJobQueue ().addJob (jtLEDGER_DATA, "triggers",
|
||||
BIND_TYPE (LADispatch, P_1, shared_from_this (), triggers));
|
||||
}
|
||||
|
||||
bool LedgerAcquire::addOnComplete (FUNCTION_TYPE<void (LedgerAcquire::pointer)> trigger)
|
||||
bool InboundLedger::addOnComplete (FUNCTION_TYPE<void (InboundLedger::pointer)> trigger)
|
||||
{
|
||||
boost::recursive_mutex::scoped_lock sl (mLock);
|
||||
|
||||
@@ -276,13 +276,13 @@ bool LedgerAcquire::addOnComplete (FUNCTION_TYPE<void (LedgerAcquire::pointer)>
|
||||
return true;
|
||||
}
|
||||
|
||||
void LedgerAcquire::trigger (Peer::ref peer)
|
||||
void InboundLedger::trigger (Peer::ref peer)
|
||||
{
|
||||
boost::recursive_mutex::scoped_lock sl (mLock);
|
||||
|
||||
if (isDone ())
|
||||
{
|
||||
WriteLog (lsDEBUG, LedgerAcquire) << "Trigger on ledger: " << mHash <<
|
||||
WriteLog (lsDEBUG, InboundLedger) << "Trigger on ledger: " << mHash <<
|
||||
(mAborted ? " aborted" : "") << (mComplete ? " completed" : "") << (mFailed ? " failed" : "");
|
||||
return;
|
||||
}
|
||||
@@ -290,21 +290,21 @@ void LedgerAcquire::trigger (Peer::ref peer)
|
||||
if ((mWaitCount > 0) && peer)
|
||||
{
|
||||
mRecentPeers.push_back (peer->getPeerId ());
|
||||
WriteLog (lsTRACE, LedgerAcquire) << "Deferring peer";
|
||||
WriteLog (lsTRACE, InboundLedger) << "Deferring peer";
|
||||
return;
|
||||
}
|
||||
|
||||
if (ShouldLog (lsTRACE, LedgerAcquire))
|
||||
if (ShouldLog (lsTRACE, InboundLedger))
|
||||
{
|
||||
if (peer)
|
||||
WriteLog (lsTRACE, LedgerAcquire) << "Trigger acquiring ledger " << mHash << " from " << peer->getIP ();
|
||||
WriteLog (lsTRACE, InboundLedger) << "Trigger acquiring ledger " << mHash << " from " << peer->getIP ();
|
||||
else
|
||||
WriteLog (lsTRACE, LedgerAcquire) << "Trigger acquiring ledger " << mHash;
|
||||
WriteLog (lsTRACE, InboundLedger) << "Trigger acquiring ledger " << mHash;
|
||||
|
||||
if (mComplete || mFailed)
|
||||
WriteLog (lsTRACE, LedgerAcquire) << "complete=" << mComplete << " failed=" << mFailed;
|
||||
WriteLog (lsTRACE, InboundLedger) << "complete=" << mComplete << " failed=" << mFailed;
|
||||
else
|
||||
WriteLog (lsTRACE, LedgerAcquire) << "base=" << mHaveBase << " tx=" << mHaveTransactions << " as=" << mHaveState;
|
||||
WriteLog (lsTRACE, InboundLedger) << "base=" << mHaveBase << " tx=" << mHaveTransactions << " as=" << mHaveState;
|
||||
}
|
||||
|
||||
if (!mHaveBase)
|
||||
@@ -313,7 +313,7 @@ void LedgerAcquire::trigger (Peer::ref peer)
|
||||
|
||||
if (mFailed)
|
||||
{
|
||||
WriteLog (lsWARNING, LedgerAcquire) << " failed local for " << mHash;
|
||||
WriteLog (lsWARNING, InboundLedger) << " failed local for " << mHash;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -336,7 +336,7 @@ void LedgerAcquire::trigger (Peer::ref peer)
|
||||
bool typeSet = false;
|
||||
BOOST_FOREACH (neededHash_t & p, need)
|
||||
{
|
||||
WriteLog (lsWARNING, LedgerAcquire) << "Want: " << p.second;
|
||||
WriteLog (lsWARNING, InboundLedger) << "Want: " << p.second;
|
||||
|
||||
if (!typeSet)
|
||||
{
|
||||
@@ -366,11 +366,11 @@ void LedgerAcquire::trigger (Peer::ref peer)
|
||||
}
|
||||
}
|
||||
}
|
||||
WriteLog (lsINFO, LedgerAcquire) << "Attempting by hash fetch for ledger " << mHash;
|
||||
WriteLog (lsINFO, InboundLedger) << "Attempting by hash fetch for ledger " << mHash;
|
||||
}
|
||||
else
|
||||
{
|
||||
WriteLog (lsINFO, LedgerAcquire) << "getNeededHashes says acquire is complete";
|
||||
WriteLog (lsINFO, InboundLedger) << "getNeededHashes says acquire is complete";
|
||||
mHaveBase = true;
|
||||
mHaveTransactions = true;
|
||||
mHaveState = true;
|
||||
@@ -382,7 +382,7 @@ void LedgerAcquire::trigger (Peer::ref peer)
|
||||
if (!mHaveBase && !mFailed)
|
||||
{
|
||||
tmGL.set_itype (ripple::liBASE);
|
||||
WriteLog (lsTRACE, LedgerAcquire) << "Sending base request to " << (peer ? "selected peer" : "all peers");
|
||||
WriteLog (lsTRACE, InboundLedger) << "Sending base request to " << (peer ? "selected peer" : "all peers");
|
||||
sendRequest (tmGL, peer);
|
||||
return;
|
||||
}
|
||||
@@ -399,7 +399,7 @@ void LedgerAcquire::trigger (Peer::ref peer)
|
||||
// we need the root node
|
||||
tmGL.set_itype (ripple::liTX_NODE);
|
||||
* (tmGL.add_nodeids ()) = SHAMapNode ().getRawString ();
|
||||
WriteLog (lsTRACE, LedgerAcquire) << "Sending TX root request to " << (peer ? "selected peer" : "all peers");
|
||||
WriteLog (lsTRACE, InboundLedger) << "Sending TX root request to " << (peer ? "selected peer" : "all peers");
|
||||
sendRequest (tmGL, peer);
|
||||
}
|
||||
else
|
||||
@@ -435,7 +435,7 @@ void LedgerAcquire::trigger (Peer::ref peer)
|
||||
{
|
||||
* (tmGL.add_nodeids ()) = it.getRawString ();
|
||||
}
|
||||
WriteLog (lsTRACE, LedgerAcquire) << "Sending TX node " << nodeIDs.size ()
|
||||
WriteLog (lsTRACE, InboundLedger) << "Sending TX node " << nodeIDs.size ()
|
||||
<< " request to " << (peer ? "selected peer" : "all peers");
|
||||
sendRequest (tmGL, peer);
|
||||
}
|
||||
@@ -452,7 +452,7 @@ void LedgerAcquire::trigger (Peer::ref peer)
|
||||
// we need the root node
|
||||
tmGL.set_itype (ripple::liAS_NODE);
|
||||
* (tmGL.add_nodeids ()) = SHAMapNode ().getRawString ();
|
||||
WriteLog (lsTRACE, LedgerAcquire) << "Sending AS root request to " << (peer ? "selected peer" : "all peers");
|
||||
WriteLog (lsTRACE, InboundLedger) << "Sending AS root request to " << (peer ? "selected peer" : "all peers");
|
||||
sendRequest (tmGL, peer);
|
||||
}
|
||||
else
|
||||
@@ -486,9 +486,9 @@ void LedgerAcquire::trigger (Peer::ref peer)
|
||||
tmGL.set_itype (ripple::liAS_NODE);
|
||||
BOOST_FOREACH (SHAMapNode & it, nodeIDs)
|
||||
* (tmGL.add_nodeids ()) = it.getRawString ();
|
||||
WriteLog (lsTRACE, LedgerAcquire) << "Sending AS node " << nodeIDs.size ()
|
||||
WriteLog (lsTRACE, InboundLedger) << "Sending AS node " << nodeIDs.size ()
|
||||
<< " request to " << (peer ? "selected peer" : "all peers");
|
||||
CondLog (nodeIDs.size () == 1, lsTRACE, LedgerAcquire) << "AS node: " << nodeIDs[0];
|
||||
CondLog (nodeIDs.size () == 1, lsTRACE, InboundLedger) << "AS node: " << nodeIDs[0];
|
||||
sendRequest (tmGL, peer);
|
||||
}
|
||||
}
|
||||
@@ -499,7 +499,7 @@ void LedgerAcquire::trigger (Peer::ref peer)
|
||||
|
||||
if (mComplete || mFailed)
|
||||
{
|
||||
WriteLog (lsDEBUG, LedgerAcquire) << "Done:" << (mComplete ? " complete" : "") << (mFailed ? " failed " : " ")
|
||||
WriteLog (lsDEBUG, InboundLedger) << "Done:" << (mComplete ? " complete" : "") << (mFailed ? " failed " : " ")
|
||||
<< mLedger->getLedgerSeq ();
|
||||
sl.unlock ();
|
||||
done ();
|
||||
@@ -558,7 +558,7 @@ int PeerSet::getPeerCount () const
|
||||
return ret;
|
||||
}
|
||||
|
||||
void LedgerAcquire::filterNodes (std::vector<SHAMapNode>& nodeIDs, std::vector<uint256>& nodeHashes,
|
||||
void InboundLedger::filterNodes (std::vector<SHAMapNode>& nodeIDs, std::vector<uint256>& nodeHashes,
|
||||
std::set<SHAMapNode>& recentNodes, int max, bool aggressive)
|
||||
{
|
||||
// ask for new nodes in preference to ones we've already asked for
|
||||
@@ -606,7 +606,7 @@ void LedgerAcquire::filterNodes (std::vector<SHAMapNode>& nodeIDs, std::vector<u
|
||||
++insertPoint;
|
||||
}
|
||||
|
||||
WriteLog (lsTRACE, LedgerAcquire) << "filterNodes " << nodeIDs.size () << " to " << insertPoint;
|
||||
WriteLog (lsTRACE, InboundLedger) << "filterNodes " << nodeIDs.size () << " to " << insertPoint;
|
||||
nodeIDs.resize (insertPoint);
|
||||
nodeHashes.resize (insertPoint);
|
||||
}
|
||||
@@ -621,11 +621,11 @@ void LedgerAcquire::filterNodes (std::vector<SHAMapNode>& nodeIDs, std::vector<u
|
||||
recentNodes.insert (n);
|
||||
}
|
||||
|
||||
bool LedgerAcquire::takeBase (const std::string& data) // data must not have hash prefix
|
||||
bool InboundLedger::takeBase (const std::string& data) // data must not have hash prefix
|
||||
{
|
||||
// Return value: true=normal, false=bad data
|
||||
#ifdef LA_DEBUG
|
||||
WriteLog (lsTRACE, LedgerAcquire) << "got base acquiring ledger " << mHash;
|
||||
WriteLog (lsTRACE, InboundLedger) << "got base acquiring ledger " << mHash;
|
||||
#endif
|
||||
boost::recursive_mutex::scoped_lock sl (mLock);
|
||||
|
||||
@@ -636,8 +636,8 @@ bool LedgerAcquire::takeBase (const std::string& data) // data must not have has
|
||||
|
||||
if (mLedger->getHash () != mHash)
|
||||
{
|
||||
WriteLog (lsWARNING, LedgerAcquire) << "Acquire hash mismatch";
|
||||
WriteLog (lsWARNING, LedgerAcquire) << mLedger->getHash () << "!=" << mHash;
|
||||
WriteLog (lsWARNING, InboundLedger) << "Acquire hash mismatch";
|
||||
WriteLog (lsWARNING, InboundLedger) << mLedger->getHash () << "!=" << mHash;
|
||||
mLedger.reset ();
|
||||
#ifdef TRUST_NETWORK
|
||||
assert (false);
|
||||
@@ -664,7 +664,7 @@ bool LedgerAcquire::takeBase (const std::string& data) // data must not have has
|
||||
return true;
|
||||
}
|
||||
|
||||
bool LedgerAcquire::takeTxNode (const std::list<SHAMapNode>& nodeIDs,
|
||||
bool InboundLedger::takeTxNode (const std::list<SHAMapNode>& nodeIDs,
|
||||
const std::list< Blob >& data, SHAMapAddNode& san)
|
||||
{
|
||||
boost::recursive_mutex::scoped_lock sl (mLock);
|
||||
@@ -712,17 +712,17 @@ bool LedgerAcquire::takeTxNode (const std::list<SHAMapNode>& nodeIDs,
|
||||
return true;
|
||||
}
|
||||
|
||||
bool LedgerAcquire::takeAsNode (const std::list<SHAMapNode>& nodeIDs,
|
||||
bool InboundLedger::takeAsNode (const std::list<SHAMapNode>& nodeIDs,
|
||||
const std::list< Blob >& data, SHAMapAddNode& san)
|
||||
{
|
||||
WriteLog (lsTRACE, LedgerAcquire) << "got ASdata (" << nodeIDs.size () << ") acquiring ledger " << mHash;
|
||||
CondLog (nodeIDs.size () == 1, lsTRACE, LedgerAcquire) << "got AS node: " << nodeIDs.front ();
|
||||
WriteLog (lsTRACE, InboundLedger) << "got ASdata (" << nodeIDs.size () << ") acquiring ledger " << mHash;
|
||||
CondLog (nodeIDs.size () == 1, lsTRACE, InboundLedger) << "got AS node: " << nodeIDs.front ();
|
||||
|
||||
boost::recursive_mutex::scoped_lock sl (mLock);
|
||||
|
||||
if (!mHaveBase)
|
||||
{
|
||||
WriteLog (lsWARNING, LedgerAcquire) << "Don't have ledger base";
|
||||
WriteLog (lsWARNING, InboundLedger) << "Don't have ledger base";
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -740,13 +740,13 @@ bool LedgerAcquire::takeAsNode (const std::list<SHAMapNode>& nodeIDs,
|
||||
if (!san.combine (mLedger->peekAccountStateMap ()->addRootNode (mLedger->getAccountHash (),
|
||||
*nodeDatait, snfWIRE, &tFilter)))
|
||||
{
|
||||
WriteLog (lsWARNING, LedgerAcquire) << "Bad ledger base";
|
||||
WriteLog (lsWARNING, InboundLedger) << "Bad ledger base";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (!san.combine (mLedger->peekAccountStateMap ()->addKnownNode (*nodeIDit, *nodeDatait, &tFilter)))
|
||||
{
|
||||
WriteLog (lsWARNING, LedgerAcquire) << "Unable to add AS node";
|
||||
WriteLog (lsWARNING, InboundLedger) << "Unable to add AS node";
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -769,7 +769,7 @@ bool LedgerAcquire::takeAsNode (const std::list<SHAMapNode>& nodeIDs,
|
||||
return true;
|
||||
}
|
||||
|
||||
bool LedgerAcquire::takeAsRootNode (Blob const& data, SHAMapAddNode& san)
|
||||
bool InboundLedger::takeAsRootNode (Blob const& data, SHAMapAddNode& san)
|
||||
{
|
||||
boost::recursive_mutex::scoped_lock sl (mLock);
|
||||
|
||||
@@ -784,7 +784,7 @@ bool LedgerAcquire::takeAsRootNode (Blob const& data, SHAMapAddNode& san)
|
||||
mLedger->peekAccountStateMap ()->addRootNode (mLedger->getAccountHash (), data, snfWIRE, &tFilter));
|
||||
}
|
||||
|
||||
bool LedgerAcquire::takeTxRootNode (Blob const& data, SHAMapAddNode& san)
|
||||
bool InboundLedger::takeTxRootNode (Blob const& data, SHAMapAddNode& san)
|
||||
{
|
||||
boost::recursive_mutex::scoped_lock sl (mLock);
|
||||
|
||||
@@ -799,7 +799,7 @@ bool LedgerAcquire::takeTxRootNode (Blob const& data, SHAMapAddNode& san)
|
||||
mLedger->peekTransactionMap ()->addRootNode (mLedger->getTransHash (), data, snfWIRE, &tFilter));
|
||||
}
|
||||
|
||||
std::vector<LedgerAcquire::neededHash_t> LedgerAcquire::getNeededHashes ()
|
||||
std::vector<InboundLedger::neededHash_t> InboundLedger::getNeededHashes ()
|
||||
{
|
||||
std::vector<neededHash_t> ret;
|
||||
|
||||
@@ -828,7 +828,7 @@ std::vector<LedgerAcquire::neededHash_t> LedgerAcquire::getNeededHashes ()
|
||||
return ret;
|
||||
}
|
||||
|
||||
Json::Value LedgerAcquire::getJson (int)
|
||||
Json::Value InboundLedger::getJson (int)
|
||||
{
|
||||
Json::Value ret (Json::objectValue);
|
||||
ret["hash"] = mHash.GetHex ();
|
||||
@@ -4,24 +4,24 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#ifndef RIPPLE_LEDGERACQUIRE_H
|
||||
#define RIPPLE_LEDGERACQUIRE_H
|
||||
#ifndef RIPPLE_INBOUNDLEDGER_H
|
||||
#define RIPPLE_INBOUNDLEDGER_H
|
||||
|
||||
DEFINE_INSTANCE (LedgerAcquire);
|
||||
DEFINE_INSTANCE (InboundLedger);
|
||||
|
||||
// VFALCO TODO Rename to InboundLedger
|
||||
// A ledger we are trying to acquire
|
||||
class LedgerAcquire : private IS_INSTANCE (LedgerAcquire)
|
||||
class InboundLedger : private IS_INSTANCE (InboundLedger)
|
||||
, public PeerSet
|
||||
, public boost::enable_shared_from_this <LedgerAcquire>
|
||||
, public boost::enable_shared_from_this <InboundLedger>
|
||||
{
|
||||
public:
|
||||
typedef boost::shared_ptr <LedgerAcquire> pointer;
|
||||
typedef boost::shared_ptr <InboundLedger> pointer;
|
||||
|
||||
public:
|
||||
LedgerAcquire (uint256 const& hash, uint32 seq);
|
||||
InboundLedger (uint256 const& hash, uint32 seq);
|
||||
|
||||
virtual ~LedgerAcquire ()
|
||||
virtual ~InboundLedger ()
|
||||
{
|
||||
;
|
||||
}
|
||||
@@ -63,7 +63,7 @@ public:
|
||||
}
|
||||
|
||||
// VFALCO TODO Make thise the Listener / Observer pattern
|
||||
bool addOnComplete (FUNCTION_TYPE<void (LedgerAcquire::pointer)>);
|
||||
bool addOnComplete (FUNCTION_TYPE<void (InboundLedger::pointer)>);
|
||||
|
||||
bool takeBase (const std::string& data);
|
||||
bool takeTxNode (const std::list<SHAMapNode>& IDs, const std::list<Blob >& data,
|
||||
@@ -117,7 +117,7 @@ private:
|
||||
|
||||
std::vector <uint64> mRecentPeers;
|
||||
|
||||
std::vector <FUNCTION_TYPE <void (LedgerAcquire::pointer)> > mOnComplete;
|
||||
std::vector <FUNCTION_TYPE <void (InboundLedger::pointer)> > mOnComplete;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -4,11 +4,11 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
LedgerAcquire::pointer LedgerAcquireMaster::findCreate (uint256 const& hash, uint32 seq)
|
||||
InboundLedger::pointer InboundLedgers::findCreate (uint256 const& hash, uint32 seq)
|
||||
{
|
||||
assert (hash.isNonZero ());
|
||||
boost::mutex::scoped_lock sl (mLock);
|
||||
LedgerAcquire::pointer& ptr = mLedgers[hash];
|
||||
InboundLedger::pointer& ptr = mLedgers[hash];
|
||||
|
||||
if (ptr)
|
||||
{
|
||||
@@ -16,7 +16,7 @@ LedgerAcquire::pointer LedgerAcquireMaster::findCreate (uint256 const& hash, uin
|
||||
return ptr;
|
||||
}
|
||||
|
||||
ptr = boost::make_shared<LedgerAcquire> (hash, seq);
|
||||
ptr = boost::make_shared<InboundLedger> (hash, seq);
|
||||
|
||||
if (!ptr->isDone ())
|
||||
{
|
||||
@@ -29,17 +29,17 @@ LedgerAcquire::pointer LedgerAcquireMaster::findCreate (uint256 const& hash, uin
|
||||
ledger->setClosed ();
|
||||
ledger->setImmutable ();
|
||||
theApp->getLedgerMaster ().storeLedger (ledger);
|
||||
WriteLog (lsDEBUG, LedgerAcquire) << "Acquiring ledger we already have: " << hash;
|
||||
WriteLog (lsDEBUG, InboundLedger) << "Acquiring ledger we already have: " << hash;
|
||||
}
|
||||
|
||||
return ptr;
|
||||
}
|
||||
|
||||
LedgerAcquire::pointer LedgerAcquireMaster::find (uint256 const& hash)
|
||||
InboundLedger::pointer InboundLedgers::find (uint256 const& hash)
|
||||
{
|
||||
assert (hash.isNonZero ());
|
||||
boost::mutex::scoped_lock sl (mLock);
|
||||
std::map<uint256, LedgerAcquire::pointer>::iterator it = mLedgers.find (hash);
|
||||
std::map<uint256, InboundLedger::pointer>::iterator it = mLedgers.find (hash);
|
||||
|
||||
if (it != mLedgers.end ())
|
||||
{
|
||||
@@ -47,26 +47,26 @@ LedgerAcquire::pointer LedgerAcquireMaster::find (uint256 const& hash)
|
||||
return it->second;
|
||||
}
|
||||
|
||||
return LedgerAcquire::pointer ();
|
||||
return InboundLedger::pointer ();
|
||||
}
|
||||
|
||||
bool LedgerAcquireMaster::hasLedger (uint256 const& hash)
|
||||
bool InboundLedgers::hasLedger (uint256 const& hash)
|
||||
{
|
||||
assert (hash.isNonZero ());
|
||||
boost::mutex::scoped_lock sl (mLock);
|
||||
return mLedgers.find (hash) != mLedgers.end ();
|
||||
}
|
||||
|
||||
void LedgerAcquireMaster::dropLedger (uint256 const& hash)
|
||||
void InboundLedgers::dropLedger (uint256 const& hash)
|
||||
{
|
||||
assert (hash.isNonZero ());
|
||||
boost::mutex::scoped_lock sl (mLock);
|
||||
mLedgers.erase (hash);
|
||||
}
|
||||
|
||||
bool LedgerAcquireMaster::awaitLedgerData (uint256 const& ledgerHash)
|
||||
bool InboundLedgers::awaitLedgerData (uint256 const& ledgerHash)
|
||||
{
|
||||
LedgerAcquire::pointer ledger = find (ledgerHash);
|
||||
InboundLedger::pointer ledger = find (ledgerHash);
|
||||
|
||||
if (!ledger)
|
||||
return false;
|
||||
@@ -75,19 +75,19 @@ bool LedgerAcquireMaster::awaitLedgerData (uint256 const& ledgerHash)
|
||||
return true;
|
||||
}
|
||||
|
||||
void LedgerAcquireMaster::gotLedgerData (Job&, uint256 hash,
|
||||
void InboundLedgers::gotLedgerData (Job&, uint256 hash,
|
||||
boost::shared_ptr<ripple::TMLedgerData> packet_ptr, boost::weak_ptr<Peer> wPeer)
|
||||
{
|
||||
ripple::TMLedgerData& packet = *packet_ptr;
|
||||
Peer::pointer peer = wPeer.lock ();
|
||||
|
||||
WriteLog (lsTRACE, LedgerAcquire) << "Got data (" << packet.nodes ().size () << ") for acquiring ledger: " << hash;
|
||||
WriteLog (lsTRACE, InboundLedger) << "Got data (" << packet.nodes ().size () << ") for acquiring ledger: " << hash;
|
||||
|
||||
LedgerAcquire::pointer ledger = find (hash);
|
||||
InboundLedger::pointer ledger = find (hash);
|
||||
|
||||
if (!ledger)
|
||||
{
|
||||
WriteLog (lsTRACE, LedgerAcquire) << "Got data for ledger we're not acquiring";
|
||||
WriteLog (lsTRACE, InboundLedger) << "Got data for ledger we're not acquiring";
|
||||
|
||||
if (peer)
|
||||
peer->punishPeer (LT_InvalidRequest);
|
||||
@@ -104,14 +104,14 @@ void LedgerAcquireMaster::gotLedgerData (Job&, uint256 hash,
|
||||
{
|
||||
if (packet.nodes_size () < 1)
|
||||
{
|
||||
WriteLog (lsWARNING, LedgerAcquire) << "Got empty base data";
|
||||
WriteLog (lsWARNING, InboundLedger) << "Got empty base data";
|
||||
peer->punishPeer (LT_InvalidRequest);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!ledger->takeBase (packet.nodes (0).nodedata ()))
|
||||
{
|
||||
WriteLog (lsWARNING, LedgerAcquire) << "Got invalid base data";
|
||||
WriteLog (lsWARNING, InboundLedger) << "Got invalid base data";
|
||||
peer->punishPeer (LT_InvalidRequest);
|
||||
return;
|
||||
}
|
||||
@@ -120,12 +120,12 @@ void LedgerAcquireMaster::gotLedgerData (Job&, uint256 hash,
|
||||
|
||||
if ((packet.nodes ().size () > 1) && !ledger->takeAsRootNode (strCopy (packet.nodes (1).nodedata ()), san))
|
||||
{
|
||||
WriteLog (lsWARNING, LedgerAcquire) << "Included ASbase invalid";
|
||||
WriteLog (lsWARNING, InboundLedger) << "Included ASbase invalid";
|
||||
}
|
||||
|
||||
if ((packet.nodes ().size () > 2) && !ledger->takeTxRootNode (strCopy (packet.nodes (2).nodedata ()), san))
|
||||
{
|
||||
WriteLog (lsWARNING, LedgerAcquire) << "Included TXbase invalid";
|
||||
WriteLog (lsWARNING, InboundLedger) << "Included TXbase invalid";
|
||||
}
|
||||
|
||||
if (!san.isInvalid ())
|
||||
@@ -134,7 +134,7 @@ void LedgerAcquireMaster::gotLedgerData (Job&, uint256 hash,
|
||||
ledger->trigger (peer);
|
||||
}
|
||||
else
|
||||
WriteLog (lsDEBUG, LedgerAcquire) << "Peer sends invalid base data";
|
||||
WriteLog (lsDEBUG, InboundLedger) << "Peer sends invalid base data";
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -146,7 +146,7 @@ void LedgerAcquireMaster::gotLedgerData (Job&, uint256 hash,
|
||||
|
||||
if (packet.nodes ().size () <= 0)
|
||||
{
|
||||
WriteLog (lsINFO, LedgerAcquire) << "Got response with no nodes";
|
||||
WriteLog (lsINFO, InboundLedger) << "Got response with no nodes";
|
||||
peer->punishPeer (LT_InvalidRequest);
|
||||
return;
|
||||
}
|
||||
@@ -157,7 +157,7 @@ void LedgerAcquireMaster::gotLedgerData (Job&, uint256 hash,
|
||||
|
||||
if (!node.has_nodeid () || !node.has_nodedata ())
|
||||
{
|
||||
WriteLog (lsWARNING, LedgerAcquire) << "Got bad node";
|
||||
WriteLog (lsWARNING, InboundLedger) << "Got bad node";
|
||||
peer->punishPeer (LT_InvalidRequest);
|
||||
return;
|
||||
}
|
||||
@@ -179,23 +179,23 @@ void LedgerAcquireMaster::gotLedgerData (Job&, uint256 hash,
|
||||
ledger->trigger (peer);
|
||||
}
|
||||
else
|
||||
WriteLog (lsDEBUG, LedgerAcquire) << "Peer sends invalid node data";
|
||||
WriteLog (lsDEBUG, InboundLedger) << "Peer sends invalid node data";
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
WriteLog (lsWARNING, LedgerAcquire) << "Not sure what ledger data we got";
|
||||
WriteLog (lsWARNING, InboundLedger) << "Not sure what ledger data we got";
|
||||
peer->punishPeer (LT_InvalidRequest);
|
||||
}
|
||||
|
||||
void LedgerAcquireMaster::sweep ()
|
||||
void InboundLedgers::sweep ()
|
||||
{
|
||||
mRecentFailures.sweep ();
|
||||
|
||||
int now = UptimeTimer::getInstance ().getElapsedSeconds ();
|
||||
boost::mutex::scoped_lock sl (mLock);
|
||||
|
||||
std::map<uint256, LedgerAcquire::pointer>::iterator it = mLedgers.begin ();
|
||||
std::map<uint256, InboundLedger::pointer>::iterator it = mLedgers.begin ();
|
||||
|
||||
while (it != mLedgers.end ())
|
||||
{
|
||||
@@ -211,12 +211,12 @@ void LedgerAcquireMaster::sweep ()
|
||||
}
|
||||
}
|
||||
|
||||
int LedgerAcquireMaster::getFetchCount (int& timeoutCount)
|
||||
int InboundLedgers::getFetchCount (int& timeoutCount)
|
||||
{
|
||||
timeoutCount = 0;
|
||||
int ret = 0;
|
||||
{
|
||||
typedef std::pair<uint256, LedgerAcquire::pointer> u256_acq_pair;
|
||||
typedef std::pair<uint256, InboundLedger::pointer> u256_acq_pair;
|
||||
boost::mutex::scoped_lock sl (mLock);
|
||||
BOOST_FOREACH (const u256_acq_pair & it, mLedgers)
|
||||
{
|
||||
@@ -230,19 +230,19 @@ int LedgerAcquireMaster::getFetchCount (int& timeoutCount)
|
||||
return ret;
|
||||
}
|
||||
|
||||
void LedgerAcquireMaster::gotFetchPack (Job&)
|
||||
void InboundLedgers::gotFetchPack (Job&)
|
||||
{
|
||||
std::vector<LedgerAcquire::pointer> acquires;
|
||||
std::vector<InboundLedger::pointer> acquires;
|
||||
{
|
||||
boost::mutex::scoped_lock sl (mLock);
|
||||
|
||||
acquires.reserve (mLedgers.size ());
|
||||
typedef std::pair<uint256, LedgerAcquire::pointer> u256_acq_pair;
|
||||
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 LedgerAcquire::pointer & acquire, acquires)
|
||||
BOOST_FOREACH (const InboundLedger::pointer & acquire, acquires)
|
||||
{
|
||||
acquire->checkLocal ();
|
||||
}
|
||||
@@ -4,37 +4,53 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#ifndef RIPPLE_LEDGERACQUIREMASTER_H
|
||||
#define RIPPLE_LEDGERACQUIREMASTER_H
|
||||
#ifndef RIPPLE_INBOUNDLEDGERS_H
|
||||
#define RIPPLE_INBOUNDLEDGERS_H
|
||||
|
||||
/** Manages the lifetime of inbound ledgers.
|
||||
|
||||
@see InboundLedger
|
||||
*/
|
||||
// VFALCO TODO Rename to InboundLedgers
|
||||
// VFALCO TODO Create abstract interface
|
||||
class LedgerAcquireMaster
|
||||
class InboundLedgers
|
||||
{
|
||||
public:
|
||||
// How long before we try again to acquire the same ledger
|
||||
static const int kReacquireIntervalSeconds = 600;
|
||||
|
||||
LedgerAcquireMaster ()
|
||||
InboundLedgers ()
|
||||
: mRecentFailures ("LedgerAcquireRecentFailures", 0, kReacquireIntervalSeconds)
|
||||
{
|
||||
}
|
||||
|
||||
LedgerAcquire::pointer findCreate (uint256 const& hash, uint32 seq);
|
||||
LedgerAcquire::pointer find (uint256 const& hash);
|
||||
bool hasLedger (uint256 const& ledgerHash);
|
||||
void dropLedger (uint256 const& ledgerHash);
|
||||
// VFALCO TODO Should this be called findOrAdd ?
|
||||
//
|
||||
InboundLedger::pointer findCreate (uint256 const& hash, uint32 seq);
|
||||
|
||||
bool awaitLedgerData (uint256 const& ledgerHash);
|
||||
void gotLedgerData (Job&, uint256 hash, boost::shared_ptr<ripple::TMLedgerData> packet, boost::weak_ptr<Peer> peer);
|
||||
InboundLedger::pointer find (uint256 const& hash);
|
||||
|
||||
bool hasLedger (LedgerHash const& ledgerHash);
|
||||
|
||||
void dropLedger (LedgerHash const& ledgerHash);
|
||||
|
||||
bool awaitLedgerData (LedgerHash const& ledgerHash);
|
||||
|
||||
// VFALCO TODO Why is hash passed by value?
|
||||
// VFALCO TODO Remove the dependency on the Peer object.
|
||||
//
|
||||
void gotLedgerData (Job&,
|
||||
LedgerHash hash,
|
||||
boost::shared_ptr <ripple::TMLedgerData> packet,
|
||||
boost::weak_ptr<Peer> peer);
|
||||
|
||||
int getFetchCount (int& timeoutCount);
|
||||
|
||||
void logFailure (uint256 const& h)
|
||||
{
|
||||
mRecentFailures.add (h);
|
||||
}
|
||||
|
||||
bool isFailure (uint256 const& h)
|
||||
{
|
||||
return mRecentFailures.isPresent (h, false);
|
||||
@@ -45,10 +61,8 @@ public:
|
||||
|
||||
private:
|
||||
boost::mutex mLock;
|
||||
std::map <uint256, LedgerAcquire::pointer> mLedgers;
|
||||
std::map <uint256, InboundLedger::pointer> mLedgers;
|
||||
KeyCache <uint256, UptimeTimerAdapter> mRecentFailures;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
// vim:ts=4
|
||||
@@ -208,9 +208,9 @@ void LedgerConsensus::handleLCL (uint256 const& lclHash)
|
||||
WriteLog (lsWARNING, LedgerConsensus) << "Need consensus ledger " << mPrevLedgerHash;
|
||||
|
||||
if (mAcquiringLedger)
|
||||
theApp->getMasterLedgerAcquire ().dropLedger (mAcquiringLedger->getHash ());
|
||||
theApp->getInboundLedgers ().dropLedger (mAcquiringLedger->getHash ());
|
||||
|
||||
mAcquiringLedger = theApp->getMasterLedgerAcquire ().findCreate (mPrevLedgerHash, 0);
|
||||
mAcquiringLedger = theApp->getInboundLedgers ().findCreate (mPrevLedgerHash, 0);
|
||||
mHaveCorrectLCL = false;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -120,7 +120,7 @@ private:
|
||||
uint32 mCloseTime; // The wall time this ledger closed
|
||||
uint256 mPrevLedgerHash, mNewLedgerHash;
|
||||
Ledger::pointer mPreviousLedger;
|
||||
LedgerAcquire::pointer mAcquiringLedger;
|
||||
InboundLedger::pointer mAcquiringLedger;
|
||||
LedgerProposal::pointer mOurPosition;
|
||||
RippleAddress mValPublic, mValPrivate;
|
||||
bool mProposing, mValidating, mHaveCorrectLCL, mConsensusFail;
|
||||
|
||||
@@ -2070,9 +2070,9 @@ void PeerImp::recvLedger (const boost::shared_ptr<ripple::TMLedgerData>& packet_
|
||||
return;
|
||||
}
|
||||
|
||||
if (theApp->getMasterLedgerAcquire ().awaitLedgerData (hash))
|
||||
if (theApp->getInboundLedgers ().awaitLedgerData (hash))
|
||||
theApp->getJobQueue ().addJob (jtLEDGER_DATA, "gotLedgerData",
|
||||
BIND_TYPE (&LedgerAcquireMaster::gotLedgerData, &theApp->getMasterLedgerAcquire (),
|
||||
BIND_TYPE (&InboundLedgers::gotLedgerData, &theApp->getInboundLedgers (),
|
||||
P_1, hash, packet_ptr, boost::weak_ptr<Peer> (shared_from_this ())));
|
||||
else
|
||||
punishPeer (LT_UnwantedData);
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
class LedgerAcquire;
|
||||
class InboundLedger;
|
||||
|
||||
PeerSet::PeerSet (uint256 const& hash, int interval)
|
||||
: mHash (hash)
|
||||
@@ -52,7 +52,7 @@ void PeerSet::invokeOnTimer ()
|
||||
if (!mProgress)
|
||||
{
|
||||
++mTimeouts;
|
||||
WriteLog (lsWARNING, LedgerAcquire) << "Timeout(" << mTimeouts << ") pc=" << mPeers.size () << " acquiring " << mHash;
|
||||
WriteLog (lsWARNING, InboundLedger) << "Timeout(" << mTimeouts << ") pc=" << mPeers.size () << " acquiring " << mHash;
|
||||
onTimer (false);
|
||||
}
|
||||
else
|
||||
@@ -78,7 +78,7 @@ void PeerSet::TimerEntry (boost::weak_ptr<PeerSet> wptr, const boost::system::er
|
||||
|
||||
if (jc > 4)
|
||||
{
|
||||
WriteLog (lsDEBUG, LedgerAcquire) << "Deferring PeerSet timer due to load";
|
||||
WriteLog (lsDEBUG, InboundLedger) << "Deferring PeerSet timer due to load";
|
||||
ptr->setTimer ();
|
||||
}
|
||||
else
|
||||
|
||||
@@ -22,7 +22,7 @@ static void TACompletionHandler (uint256 hash, SHAMap::pointer map)
|
||||
{
|
||||
boost::recursive_mutex::scoped_lock sl (theApp->getMasterLock ());
|
||||
theApp->getOPs ().mapComplete (hash, map);
|
||||
theApp->getMasterLedgerAcquire ().dropLedger (hash);
|
||||
theApp->getInboundLedgers ().dropLedger (hash);
|
||||
}
|
||||
|
||||
void TransactionAcquire::done ()
|
||||
|
||||
Reference in New Issue
Block a user