mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Add a getLedgerNext that takes into account changes in the LES.
This commit is contained in:
@@ -903,6 +903,39 @@ bool LedgerEntrySet::dirNext(
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint256 LedgerEntrySet::getNextLedgerIndex(const uint256& uHash)
|
||||||
|
{
|
||||||
|
// find next node in ledger that isn't deleted by LES
|
||||||
|
uint256 ledgerNext = uHash;
|
||||||
|
std::map<uint256, LedgerEntrySetEntry>::const_iterator it;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
ledgerNext = mLedger->getNextLedgerIndex(ledgerNext);
|
||||||
|
it = mEntries.find(ledgerNext);
|
||||||
|
} while ((it != mEntries.end()) && (it->second.mAction == taaDELETE));
|
||||||
|
|
||||||
|
// find next node in LES that isn't deleted
|
||||||
|
for (it = mEntries.upper_bound(uHash); it != mEntries.end(); ++it)
|
||||||
|
{
|
||||||
|
|
||||||
|
// node found in LES, node found in ledger, return earliest
|
||||||
|
if (it->second.mAction != taaDELETE)
|
||||||
|
return (ledgerNext < it->first) ? ledgerNext : it->first;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// nothing next in LES, return next ledger node
|
||||||
|
return ledgerNext;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint256 LedgerEntrySet::getNextLedgerIndex(const uint256& uHash, const uint256& uEnd)
|
||||||
|
{
|
||||||
|
uint256 next = getNextLedgerIndex(uHash);
|
||||||
|
if (next > uEnd)
|
||||||
|
return uint256();
|
||||||
|
return next;
|
||||||
|
}
|
||||||
|
|
||||||
// If there is a count, adjust the owner count by iAmount. Otherwise, compute the owner count and store it.
|
// If there is a count, adjust the owner count by iAmount. Otherwise, compute the owner count and store it.
|
||||||
void LedgerEntrySet::ownerCountAdjust(const uint160& uOwnerID, int iAmount, SLE::ref sleAccountRoot)
|
void LedgerEntrySet::ownerCountAdjust(const uint160& uOwnerID, int iAmount, SLE::ref sleAccountRoot)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -126,6 +126,9 @@ public:
|
|||||||
bool dirNext(const uint256& uRootIndex, SLE::pointer& sleNode, unsigned int& uDirEntry, uint256& uEntryIndex);
|
bool dirNext(const uint256& uRootIndex, SLE::pointer& sleNode, unsigned int& uDirEntry, uint256& uEntryIndex);
|
||||||
TER dirCount(const uint256& uDirIndex, uint32& uCount);
|
TER dirCount(const uint256& uDirIndex, uint32& uCount);
|
||||||
|
|
||||||
|
uint256 getNextLedgerIndex(const uint256& uHash);
|
||||||
|
uint256 getNextLedgerIndex(const uint256& uHash, const uint256& uEnd);
|
||||||
|
|
||||||
void ownerCountAdjust(const uint160& uOwnerID, int iAmount, SLE::ref sleAccountRoot=SLE::pointer());
|
void ownerCountAdjust(const uint160& uOwnerID, int iAmount, SLE::ref sleAccountRoot=SLE::pointer());
|
||||||
|
|
||||||
// Offer functions.
|
// Offer functions.
|
||||||
|
|||||||
@@ -889,7 +889,7 @@ TER RippleCalc::calcNodeAdvance(
|
|||||||
// FIXME: This looks at the original ledger and doesn't take into account any changes
|
// FIXME: This looks at the original ledger and doesn't take into account any changes
|
||||||
// in the LedgerEntrySet. If this code, for example, created offers, this would
|
// in the LedgerEntrySet. If this code, for example, created offers, this would
|
||||||
// not return the pages they're in.
|
// not return the pages they're in.
|
||||||
uDirectTip = lesActive.getLedger()->getNextLedgerIndex(uDirectTip, uDirectEnd);
|
uDirectTip = lesActive.getNextLedgerIndex(uDirectTip, uDirectEnd);
|
||||||
|
|
||||||
bDirectDirDirty = true;
|
bDirectDirDirty = true;
|
||||||
bDirectAdvance = false;
|
bDirectAdvance = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user