Merge branch 'fetch_fix'

This commit is contained in:
JoelKatz
2013-05-17 01:06:03 -07:00
7 changed files with 32 additions and 8 deletions

View File

@@ -695,7 +695,8 @@ void LedgerConsensus::updateOurPositions()
for (std::map<uint32, int>::iterator it = closeTimes.begin(), end = closeTimes.end(); it != end; ++it)
{
cLog(lsDEBUG) << "CCTime: " << it->first << " has " << it->second << ", " << threshVote << " required";
cLog(lsDEBUG) << "CCTime: seq" << mPreviousLedger->getLedgerSeq() + 1 << ": " <<
it->first << " has " << it->second << ", " << threshVote << " required";
if (it->second >= threshVote)
{
cLog(lsDEBUG) << "Close time consensus reached: " << it->first;

View File

@@ -557,7 +557,10 @@ void LedgerMaster::checkAccept(const uint256& hash, uint32 seq)
Ledger::pointer ledger = mLedgerHistory.getLedgerByHash(hash);
if (!ledger)
{
theApp->getMasterLedgerAcquire().findCreate(hash, seq);
return;
}
mValidLedger = ledger;
tryPublish();
@@ -575,6 +578,8 @@ void LedgerMaster::tryPublish()
}
else if (mValidLedger->getLedgerSeq() > (mPubLedger->getLedgerSeq() + MAX_LEDGER_GAP))
{
cLog(lsWARNING) << "Gap in validated ledger stream " << mPubLedger->getLedgerSeq() << " - " <<
mValidLedger->getLedgerSeq() - 1;
mPubLedger = mValidLedger;
mPubLedgers.push_back(mValidLedger);
}
@@ -613,11 +618,11 @@ void LedgerMaster::tryPublish()
{
if (theApp->getMasterLedgerAcquire().isFailure(hash))
{
cLog(lsFATAL) << "Unable to acquire a recent validated ledger";
cLog(lsWARNING) << "Unable to acquire a recent validated ledger";
}
else
{
LedgerAcquire::pointer acq = theApp->getMasterLedgerAcquire().findCreate(hash, 0);
LedgerAcquire::pointer acq = theApp->getMasterLedgerAcquire().findCreate(hash, seq);
if (!acq->isDone())
{
acq->setAccept();

View File

@@ -285,6 +285,12 @@ bool LoadFeeTrack::raiseLocalFee()
return true;
}
bool LoadFeeTrack::isLoaded()
{
boost::mutex::scoped_lock sl(mLock);
return (raiseCount != 0) || (mLocalTxnLoadFee != lftNormalFee);
}
bool LoadFeeTrack::lowerLocalFee()
{
boost::mutex::scoped_lock sl(mLock);

View File

@@ -185,7 +185,7 @@ public:
void setRemoteFee(uint32);
bool raiseLocalFee();
bool lowerLocalFee();
bool isLoaded() { return (raiseCount != 0) || (mLocalTxnLoadFee != lftNormalFee); }
bool isLoaded();
};

View File

@@ -2004,9 +2004,21 @@ void NetworkOPs::getBookPage(Ledger::pointer lpLedger, const uint160& uTakerPays
// jvResult["nodes"] = Json::Value(Json::arrayValue);
}
void NetworkOPs::makeFetchPack(Job&, boost::weak_ptr<Peer> wPeer, boost::shared_ptr<ripple::TMGetObjectByHash> request,
Ledger::pointer wantLedger, Ledger::pointer haveLedger)
void NetworkOPs::makeFetchPack(Job&, boost::weak_ptr<Peer> wPeer,
boost::shared_ptr<ripple::TMGetObjectByHash> request,
Ledger::pointer wantLedger, Ledger::pointer haveLedger, uint32 uUptime)
{
if (upTime() > (uUptime + 1))
{
cLog(lsINFO) << "Fetch pack request got stale";
return;
}
if (theApp->getFeeTrack().isLoaded())
{
cLog(lsINFO) << "Too busy to make fetch pack";
return;
}
try
{
Peer::pointer peer = wPeer.lock();

View File

@@ -283,7 +283,7 @@ public:
void mapComplete(const uint256& hash, SHAMap::ref map);
bool stillNeedTXSet(const uint256& hash);
void makeFetchPack(Job&, boost::weak_ptr<Peer> peer, boost::shared_ptr<ripple::TMGetObjectByHash> request,
Ledger::pointer wantLedger, Ledger::pointer haveLedger);
Ledger::pointer wantLedger, Ledger::pointer haveLedger, uint32 uUptime);
bool shouldFetchPack(uint32 seq);
void gotFetchPack(bool progress, uint32 seq);
void addFetchPack(const uint256& hash, boost::shared_ptr< std::vector<unsigned char> >& data);

View File

@@ -1911,7 +1911,7 @@ void Peer::doFetchPack(const boost::shared_ptr<ripple::TMGetObjectByHash>& packe
}
theApp->getJobQueue().addJob(jtPACK, "MakeFetchPack",
BIND_TYPE(&NetworkOPs::makeFetchPack, &theApp->getOPs(), P_1,
boost::weak_ptr<Peer>(shared_from_this()), packet, wantLedger, haveLedger));
boost::weak_ptr<Peer>(shared_from_this()), packet, wantLedger, haveLedger, upTime()));
}
bool Peer::hasProto(int version)