mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-30 16:05:51 +00:00
Fix some cases where ledger flags are incorrectly set.
This commit is contained in:
@@ -113,14 +113,31 @@ Ledger::Ledger(const std::string& rawLedger, bool hasPrefix) :
|
||||
zeroFees();
|
||||
}
|
||||
|
||||
void Ledger::setImmutable()
|
||||
{
|
||||
if (!mImmutable)
|
||||
{
|
||||
updateHash();
|
||||
mImmutable = true;
|
||||
if (mTransactionMap)
|
||||
mTransactionMap->setImmutable();
|
||||
if (mAccountStateMap)
|
||||
mAccountStateMap->setImmutable();
|
||||
}
|
||||
}
|
||||
|
||||
void Ledger::updateHash()
|
||||
{
|
||||
if (!mImmutable)
|
||||
{
|
||||
if (mTransactionMap) mTransHash = mTransactionMap->getHash();
|
||||
else mTransHash.zero();
|
||||
if (mAccountStateMap) mAccountHash = mAccountStateMap->getHash();
|
||||
else mAccountHash.zero();
|
||||
if (mTransactionMap)
|
||||
mTransHash = mTransactionMap->getHash();
|
||||
else
|
||||
mTransHash.zero();
|
||||
if (mAccountStateMap)
|
||||
mAccountHash = mAccountStateMap->getHash();
|
||||
else
|
||||
mAccountHash.zero();
|
||||
}
|
||||
|
||||
Serializer s(118);
|
||||
@@ -170,18 +187,17 @@ void Ledger::setAccepted(uint32 closeTime, int closeResolution, bool correctClos
|
||||
mCloseTime = correctCloseTime ? (closeTime - (closeTime % closeResolution)) : closeTime;
|
||||
mCloseResolution = closeResolution;
|
||||
mCloseFlags = correctCloseTime ? 0 : sLCF_NoConsensusTime;
|
||||
updateHash();
|
||||
mAccepted = true;
|
||||
mImmutable = true;
|
||||
setImmutable();
|
||||
}
|
||||
|
||||
void Ledger::setAccepted()
|
||||
{ // used when we acquired the ledger
|
||||
// FIXME assert(mClosed && (mCloseTime != 0) && (mCloseResolution != 0));
|
||||
mCloseTime -= mCloseTime % mCloseResolution;
|
||||
updateHash();
|
||||
if ((mCloseFlags & sLCF_NoConsensusTime) == 0)
|
||||
mCloseTime -= mCloseTime % mCloseResolution;
|
||||
mAccepted = true;
|
||||
mImmutable = true;
|
||||
setImmutable();
|
||||
}
|
||||
|
||||
AccountState::pointer Ledger::getAccountState(const RippleAddress& accountID)
|
||||
@@ -527,6 +543,8 @@ Ledger::pointer Ledger::getSQL(const std::string& sql)
|
||||
Ledger::pointer ret = boost::make_shared<Ledger>(prevHash, transHash, accountHash, totCoins,
|
||||
closingTime, prevClosingTime, closeFlags, closeResolution, ledgerSeq);
|
||||
ret->setClosed();
|
||||
if (theApp->getOPs().haveLedger(ledgerSeq))
|
||||
ret->setAccepted();
|
||||
if (ret->getHash() != ledgerHash)
|
||||
{
|
||||
if (sLog(lsERROR))
|
||||
|
||||
@@ -124,7 +124,7 @@ public:
|
||||
void setClosed() { mClosed = true; }
|
||||
void setAccepted(uint32 closeTime, int closeResolution, bool correctCloseTime);
|
||||
void setAccepted();
|
||||
void setImmutable() { updateHash(); mImmutable = true; }
|
||||
void setImmutable();
|
||||
bool isClosed() { return mClosed; }
|
||||
bool isAccepted() { return mAccepted; }
|
||||
bool isImmutable() { return mImmutable; }
|
||||
|
||||
@@ -160,6 +160,7 @@ bool LedgerAcquire::tryLocal()
|
||||
{
|
||||
cLog(lsDEBUG) << "Had everything locally";
|
||||
mComplete = true;
|
||||
mLedger->setClosed();
|
||||
}
|
||||
|
||||
return mComplete;
|
||||
@@ -244,11 +245,9 @@ void LedgerAcquire::done()
|
||||
|
||||
if (isComplete() && !isFailed() && mLedger)
|
||||
{
|
||||
mLedger->setClosed();
|
||||
if (mAccept)
|
||||
{
|
||||
mLedger->setClosed();
|
||||
mLedger->setAccepted();
|
||||
}
|
||||
theApp->getLedgerMaster().storeLedger(mLedger);
|
||||
}
|
||||
else
|
||||
|
||||
@@ -82,7 +82,7 @@ Ledger::pointer LedgerHistory::getLedgerByHash(const uint256& hash)
|
||||
if (ret)
|
||||
{
|
||||
assert(ret->isImmutable());
|
||||
assert(ret->getHash() == hash);
|
||||
assert(ret->getHash() == hash); // FIXME: We seem to be getting these
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@@ -133,6 +133,12 @@ bool LedgerMaster::haveLedgerRange(uint32 from, uint32 to)
|
||||
return (prevMissing == RangeSet::RangeSetAbsent) || (prevMissing < from);
|
||||
}
|
||||
|
||||
bool LedgerMaster::haveLedger(uint32 seq)
|
||||
{
|
||||
boost::recursive_mutex::scoped_lock sl(mLock);
|
||||
return mCompleteLedgers.hasValue(seq);
|
||||
}
|
||||
|
||||
void LedgerMaster::asyncAccept(Ledger::pointer ledger)
|
||||
{
|
||||
uint32 seq = ledger->getLedgerSeq();
|
||||
|
||||
@@ -126,6 +126,7 @@ public:
|
||||
void fixMismatch(Ledger::ref ledger);
|
||||
|
||||
bool haveLedgerRange(uint32 from, uint32 to);
|
||||
bool haveLedger(uint32 seq);
|
||||
|
||||
void resumeAcquiring();
|
||||
|
||||
|
||||
@@ -113,6 +113,11 @@ bool NetworkOPs::haveLedgerRange(uint32 from, uint32 to)
|
||||
return mLedgerMaster->haveLedgerRange(from, to);
|
||||
}
|
||||
|
||||
bool NetworkOPs::haveLedger(uint32 seq)
|
||||
{
|
||||
return mLedgerMaster->haveLedger(seq);
|
||||
}
|
||||
|
||||
bool NetworkOPs::addWantedHash(const uint256& h)
|
||||
{
|
||||
boost::recursive_mutex::scoped_lock sl(mWantedHashLock);
|
||||
|
||||
@@ -150,6 +150,7 @@ public:
|
||||
|
||||
// Do we have this inclusive range of ledgers in our database
|
||||
bool haveLedgerRange(uint32 from, uint32 to);
|
||||
bool haveLedger(uint32 seq);
|
||||
|
||||
SerializedValidation::ref getLastValidation() { return mLastValidation; }
|
||||
void setLastValidation(SerializedValidation::ref v) { mLastValidation = v; }
|
||||
|
||||
Reference in New Issue
Block a user