mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-27 14:35:52 +00:00
Suppress some spurious non-local fetches of data.
This commit is contained in:
@@ -94,19 +94,19 @@ Ledger::Ledger(bool /* dummy */, Ledger& prevLedger) :
|
||||
zeroFees();
|
||||
}
|
||||
|
||||
Ledger::Ledger(const std::vector<unsigned char>& rawLedger) :
|
||||
Ledger::Ledger(const std::vector<unsigned char>& rawLedger, bool hasPrefix) :
|
||||
mClosed(false), mValidHash(false), mAccepted(false), mImmutable(true)
|
||||
{
|
||||
Serializer s(rawLedger);
|
||||
setRaw(s);
|
||||
setRaw(s, hasPrefix);
|
||||
zeroFees();
|
||||
}
|
||||
|
||||
Ledger::Ledger(const std::string& rawLedger) :
|
||||
Ledger::Ledger(const std::string& rawLedger, bool hasPrefix) :
|
||||
mClosed(false), mValidHash(false), mAccepted(false), mImmutable(true)
|
||||
{
|
||||
Serializer s(rawLedger);
|
||||
setRaw(s);
|
||||
setRaw(s, hasPrefix);
|
||||
zeroFees();
|
||||
}
|
||||
|
||||
@@ -127,9 +127,10 @@ void Ledger::updateHash()
|
||||
mValidHash = true;
|
||||
}
|
||||
|
||||
void Ledger::setRaw(Serializer &s)
|
||||
void Ledger::setRaw(Serializer &s, bool hasPrefix)
|
||||
{
|
||||
SerializerIterator sit(s);
|
||||
if (hasPrefix) sit.get32();
|
||||
mLedgerSeq = sit.get32();
|
||||
mTotCoins = sit.get64();
|
||||
mParentHash = sit.get256();
|
||||
|
||||
@@ -109,9 +109,8 @@ public:
|
||||
uint64 totCoins, uint32 closeTime, uint32 parentCloseTime, int closeFlags, int closeResolution,
|
||||
uint32 ledgerSeq); // used for database ledgers
|
||||
|
||||
Ledger(const std::vector<unsigned char>& rawLedger);
|
||||
|
||||
Ledger(const std::string& rawLedger);
|
||||
Ledger(const std::vector<unsigned char>& rawLedger, bool hasPrefix);
|
||||
Ledger(const std::string& rawLedger, bool hasPrefix);
|
||||
|
||||
Ledger(bool dummy, Ledger& previous); // ledger after this one
|
||||
|
||||
@@ -132,7 +131,7 @@ public:
|
||||
|
||||
// ledger signature operations
|
||||
void addRaw(Serializer &s) const;
|
||||
void setRaw(Serializer& s);
|
||||
void setRaw(Serializer& s, bool hasPrefix);
|
||||
|
||||
uint256 getHash();
|
||||
const uint256& getParentHash() const { return mParentHash; }
|
||||
|
||||
@@ -79,6 +79,7 @@ LedgerAcquire::LedgerAcquire(const uint256& hash) : PeerSet(hash, LEDGER_ACQUIRE
|
||||
#ifdef LA_DEBUG
|
||||
cLog(lsTRACE) << "Acquiring ledger " << mHash;
|
||||
#endif
|
||||
tryLocal();
|
||||
}
|
||||
|
||||
bool LedgerAcquire::tryLocal()
|
||||
@@ -87,7 +88,7 @@ bool LedgerAcquire::tryLocal()
|
||||
if (!node)
|
||||
return false;
|
||||
|
||||
mLedger = boost::make_shared<Ledger>(strCopy(node->getData()));
|
||||
mLedger = boost::make_shared<Ledger>(strCopy(node->getData()), true);
|
||||
assert(mLedger->getHash() == mHash);
|
||||
mHaveBase = true;
|
||||
|
||||
@@ -254,7 +255,8 @@ void LedgerAcquire::trigger(Peer::ref peer, bool timer)
|
||||
mLedger->peekTransactionMap()->getMissingNodes(nodeIDs, nodeHashes, 128, &tFilter);
|
||||
if (nodeIDs.empty())
|
||||
{
|
||||
if (!mLedger->peekTransactionMap()->isValid()) mFailed = true;
|
||||
if (!mLedger->peekTransactionMap()->isValid())
|
||||
mFailed = true;
|
||||
else
|
||||
{
|
||||
mHaveTransactions = true;
|
||||
@@ -294,7 +296,8 @@ void LedgerAcquire::trigger(Peer::ref peer, bool timer)
|
||||
mLedger->peekAccountStateMap()->getMissingNodes(nodeIDs, nodeHashes, 128, &aFilter);
|
||||
if (nodeIDs.empty())
|
||||
{
|
||||
if (!mLedger->peekAccountStateMap()->isValid()) mFailed = true;
|
||||
if (!mLedger->peekAccountStateMap()->isValid())
|
||||
mFailed = true;
|
||||
else
|
||||
{
|
||||
mHaveState = true;
|
||||
@@ -367,14 +370,14 @@ int PeerSet::getPeerCount() const
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool LedgerAcquire::takeBase(const std::string& data)
|
||||
bool LedgerAcquire::takeBase(const std::string& data) // data must not have hash prefix
|
||||
{ // Return value: true=normal, false=bad data
|
||||
#ifdef LA_DEBUG
|
||||
cLog(lsTRACE) << "got base acquiring ledger " << mHash;
|
||||
#endif
|
||||
boost::recursive_mutex::scoped_lock sl(mLock);
|
||||
if (mHaveBase) return true;
|
||||
mLedger = boost::make_shared<Ledger>(data);
|
||||
mLedger = boost::make_shared<Ledger>(data, false);
|
||||
if (mLedger->getHash() != mHash)
|
||||
{
|
||||
cLog(lsWARNING) << "Acquire hash mismatch";
|
||||
|
||||
Reference in New Issue
Block a user