mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-25 13:35:54 +00:00
If we detect a missing node in a ledger we're supposed to have full,
re-acquire that ledger to fill the hole.
This commit is contained in:
@@ -547,7 +547,10 @@ Ledger::pointer Ledger::loadByIndex(uint32 ledgerIndex)
|
|||||||
ledger = getSQL1(&pSt);
|
ledger = getSQL1(&pSt);
|
||||||
}
|
}
|
||||||
if (ledger)
|
if (ledger)
|
||||||
|
{
|
||||||
Ledger::getSQL2(ledger);
|
Ledger::getSQL2(ledger);
|
||||||
|
ledger->setFull();
|
||||||
|
}
|
||||||
return ledger;
|
return ledger;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -570,6 +573,7 @@ Ledger::pointer Ledger::loadByHash(const uint256& ledgerHash)
|
|||||||
{
|
{
|
||||||
assert(ledger->getHash() == ledgerHash);
|
assert(ledger->getHash() == ledgerHash);
|
||||||
Ledger::getSQL2(ledger);
|
Ledger::getSQL2(ledger);
|
||||||
|
ledger->setFull();
|
||||||
}
|
}
|
||||||
return ledger;
|
return ledger;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -133,6 +133,7 @@ public:
|
|||||||
bool isAccepted() { return mAccepted; }
|
bool isAccepted() { return mAccepted; }
|
||||||
bool isImmutable() { return mImmutable; }
|
bool isImmutable() { return mImmutable; }
|
||||||
bool isFixed() { return mClosed || mImmutable; }
|
bool isFixed() { return mClosed || mImmutable; }
|
||||||
|
void setFull() { mTransactionMap->setLedgerSeq(mLedgerSeq); mAccountStateMap->setLedgerSeq(mLedgerSeq); }
|
||||||
|
|
||||||
// ledger signature operations
|
// ledger signature operations
|
||||||
void addRaw(Serializer &s) const;
|
void addRaw(Serializer &s) const;
|
||||||
|
|||||||
@@ -2124,4 +2124,12 @@ void NetworkOPs::gotFetchPack(bool progress, uint32 seq)
|
|||||||
boost::bind(&LedgerAcquireMaster::gotFetchPack, &theApp->getMasterLedgerAcquire(), _1));
|
boost::bind(&LedgerAcquireMaster::gotFetchPack, &theApp->getMasterLedgerAcquire(), _1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NetworkOPs::missingNodeInLedger(uint32 seq)
|
||||||
|
{
|
||||||
|
cLog(lsWARNING) << "We are missing a node in ledger " << seq;
|
||||||
|
uint256 hash = theApp->getLedgerMaster().getHashBySeq(seq);
|
||||||
|
if (hash.isNonZero())
|
||||||
|
theApp->getMasterLedgerAcquire().findCreate(hash, seq);
|
||||||
|
}
|
||||||
|
|
||||||
// vim:ts=4
|
// vim:ts=4
|
||||||
|
|||||||
@@ -183,6 +183,7 @@ public:
|
|||||||
Ledger::ref getCurrentLedger() { return mLedgerMaster->getCurrentLedger(); }
|
Ledger::ref getCurrentLedger() { return mLedgerMaster->getCurrentLedger(); }
|
||||||
Ledger::pointer getLedgerByHash(const uint256& hash) { return mLedgerMaster->getLedgerByHash(hash); }
|
Ledger::pointer getLedgerByHash(const uint256& hash) { return mLedgerMaster->getLedgerByHash(hash); }
|
||||||
Ledger::pointer getLedgerBySeq(const uint32 seq);
|
Ledger::pointer getLedgerBySeq(const uint32 seq);
|
||||||
|
void missingNodeInLedger(const uint32 seq);
|
||||||
|
|
||||||
uint256 getClosedLedgerHash() { return mLedgerMaster->getClosedLedger()->getHash(); }
|
uint256 getClosedLedgerHash() { return mLedgerMaster->getClosedLedger()->getHash(); }
|
||||||
|
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ std::size_t hash_value(const uint160& u)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SHAMap::SHAMap(SHAMapType t, uint32 seq) : mSeq(seq), mState(smsModifying), mType(t)
|
SHAMap::SHAMap(SHAMapType t, uint32 seq) : mSeq(seq), mLedgerSeq(0), mState(smsModifying), mType(t)
|
||||||
{
|
{
|
||||||
if (t == smtSTATE)
|
if (t == smtSTATE)
|
||||||
mTNByID.rehash(STATE_MAP_BUCKETS);
|
mTNByID.rehash(STATE_MAP_BUCKETS);
|
||||||
@@ -63,7 +63,7 @@ SHAMap::SHAMap(SHAMapType t, uint32 seq) : mSeq(seq), mState(smsModifying), mTyp
|
|||||||
mTNByID[*root] = root;
|
mTNByID[*root] = root;
|
||||||
}
|
}
|
||||||
|
|
||||||
SHAMap::SHAMap(SHAMapType t, const uint256& hash) : mSeq(1), mState(smsSynching), mType(t)
|
SHAMap::SHAMap(SHAMapType t, const uint256& hash) : mSeq(1), mLedgerSeq(0), mState(smsSynching), mType(t)
|
||||||
{ // FIXME: Need to acquire root node
|
{ // FIXME: Need to acquire root node
|
||||||
if (t == smtSTATE)
|
if (t == smtSTATE)
|
||||||
mTNByID.rehash(STATE_MAP_BUCKETS);
|
mTNByID.rehash(STATE_MAP_BUCKETS);
|
||||||
@@ -723,6 +723,11 @@ SHAMapTreeNode::pointer SHAMap::fetchNodeExternal(const SHAMapNode& id, const ui
|
|||||||
if (!obj)
|
if (!obj)
|
||||||
{
|
{
|
||||||
// cLog(lsTRACE) << "fetchNodeExternal: missing " << hash;
|
// cLog(lsTRACE) << "fetchNodeExternal: missing " << hash;
|
||||||
|
if (mLedgerSeq != 0)
|
||||||
|
{
|
||||||
|
theApp->getOPs().missingNodeInLedger(mLedgerSeq);
|
||||||
|
mLedgerSeq = 0;
|
||||||
|
}
|
||||||
throw SHAMapMissingNode(mType, id, hash);
|
throw SHAMapMissingNode(mType, id, hash);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -345,6 +345,7 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
uint32 mSeq;
|
uint32 mSeq;
|
||||||
|
uint32 mLedgerSeq; // sequence number of ledger this is part of
|
||||||
mutable boost::recursive_mutex mLock;
|
mutable boost::recursive_mutex mLock;
|
||||||
boost::unordered_map<SHAMapNode, SHAMapTreeNode::pointer> mTNByID;
|
boost::unordered_map<SHAMapNode, SHAMapTreeNode::pointer> mTNByID;
|
||||||
|
|
||||||
@@ -395,6 +396,8 @@ public:
|
|||||||
// Remove nodes from memory
|
// Remove nodes from memory
|
||||||
void dropCache();
|
void dropCache();
|
||||||
|
|
||||||
|
void setLedgerSeq(uint32 lseq) { mLedgerSeq = lseq; }
|
||||||
|
|
||||||
// hold the map stable across operations
|
// hold the map stable across operations
|
||||||
ScopedLock Lock() const { return ScopedLock(mLock); }
|
ScopedLock Lock() const { return ScopedLock(mLock); }
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user