mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Don't blow up if we have a ledger in the ledger DB but not its root map node in the node DB.
This commit is contained in:
@@ -44,7 +44,8 @@ Ledger::Ledger(const RippleAddress& masterID, uint64 startAmount) : mTotCoins(st
|
|||||||
}
|
}
|
||||||
|
|
||||||
Ledger::Ledger(const uint256 &parentHash, const uint256 &transHash, const uint256 &accountHash,
|
Ledger::Ledger(const uint256 &parentHash, const uint256 &transHash, const uint256 &accountHash,
|
||||||
uint64 totCoins, uint32 closeTime, uint32 parentCloseTime, int closeFlags, int closeResolution, uint32 ledgerSeq)
|
uint64 totCoins, uint32 closeTime, uint32 parentCloseTime,
|
||||||
|
int closeFlags, int closeResolution, uint32 ledgerSeq, bool& loaded)
|
||||||
: mParentHash(parentHash), mTransHash(transHash), mAccountHash(accountHash), mTotCoins(totCoins),
|
: mParentHash(parentHash), mTransHash(transHash), mAccountHash(accountHash), mTotCoins(totCoins),
|
||||||
mLedgerSeq(ledgerSeq), mCloseTime(closeTime), mParentCloseTime(parentCloseTime),
|
mLedgerSeq(ledgerSeq), mCloseTime(closeTime), mParentCloseTime(parentCloseTime),
|
||||||
mCloseResolution(closeResolution), mCloseFlags(closeFlags),
|
mCloseResolution(closeResolution), mCloseFlags(closeFlags),
|
||||||
@@ -53,10 +54,27 @@ Ledger::Ledger(const uint256 &parentHash, const uint256 &transHash, const uint25
|
|||||||
mAccountStateMap(boost::make_shared<SHAMap>(smtSTATE, accountHash))
|
mAccountStateMap(boost::make_shared<SHAMap>(smtSTATE, accountHash))
|
||||||
{ // This will throw if the root nodes are not available locally
|
{ // This will throw if the root nodes are not available locally
|
||||||
updateHash();
|
updateHash();
|
||||||
if (mTransHash.isNonZero())
|
loaded = true;
|
||||||
mTransactionMap->fetchRoot(mTransHash);
|
try
|
||||||
if (mAccountHash.isNonZero())
|
{
|
||||||
mAccountStateMap->fetchRoot(mAccountHash);
|
if (mTransHash.isNonZero())
|
||||||
|
mTransactionMap->fetchRoot(mTransHash);
|
||||||
|
}
|
||||||
|
catch (...)
|
||||||
|
{
|
||||||
|
loaded = false;
|
||||||
|
cLog(lsWARNING) << "Don't have TX root for ledger";
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (mAccountHash.isNonZero())
|
||||||
|
mAccountStateMap->fetchRoot(mAccountHash);
|
||||||
|
}
|
||||||
|
catch (...)
|
||||||
|
{
|
||||||
|
loaded = false;
|
||||||
|
cLog(lsWARNING) << "Don't have AS root for ledger";
|
||||||
|
}
|
||||||
mTransactionMap->setImmutable();
|
mTransactionMap->setImmutable();
|
||||||
mAccountStateMap->setImmutable();
|
mAccountStateMap->setImmutable();
|
||||||
zeroFees();
|
zeroFees();
|
||||||
@@ -610,8 +628,11 @@ Ledger::pointer Ledger::getSQL(const std::string& sql)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// CAUTION: code below appears in two places
|
// CAUTION: code below appears in two places
|
||||||
|
bool loaded;
|
||||||
Ledger::pointer ret = boost::make_shared<Ledger>(prevHash, transHash, accountHash, totCoins,
|
Ledger::pointer ret = boost::make_shared<Ledger>(prevHash, transHash, accountHash, totCoins,
|
||||||
closingTime, prevClosingTime, closeFlags, closeResolution, ledgerSeq);
|
closingTime, prevClosingTime, closeFlags, closeResolution, ledgerSeq, loaded);
|
||||||
|
if (!loaded)
|
||||||
|
return Ledger::pointer();
|
||||||
ret->setClosed();
|
ret->setClosed();
|
||||||
if (theApp->getOPs().haveLedger(ledgerSeq))
|
if (theApp->getOPs().haveLedger(ledgerSeq))
|
||||||
ret->setAccepted();
|
ret->setAccepted();
|
||||||
@@ -662,8 +683,12 @@ Ledger::pointer Ledger::getSQL1(SqliteStatement *stmt)
|
|||||||
ledgerSeq = stmt->getUInt32(9);
|
ledgerSeq = stmt->getUInt32(9);
|
||||||
|
|
||||||
// CAUTION: code below appears in two places
|
// CAUTION: code below appears in two places
|
||||||
return boost::make_shared<Ledger>(prevHash, transHash, accountHash, totCoins,
|
bool loaded;
|
||||||
closingTime, prevClosingTime, closeFlags, closeResolution, ledgerSeq);
|
Ledger::pointer ret = boost::make_shared<Ledger>(prevHash, transHash, accountHash, totCoins,
|
||||||
|
closingTime, prevClosingTime, closeFlags, closeResolution, ledgerSeq, loaded);
|
||||||
|
if (!loaded)
|
||||||
|
return Ledger::pointer();
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Ledger::getSQL2(Ledger::ref ret)
|
void Ledger::getSQL2(Ledger::ref ret)
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ public:
|
|||||||
|
|
||||||
Ledger(const uint256 &parentHash, const uint256 &transHash, const uint256 &accountHash,
|
Ledger(const uint256 &parentHash, const uint256 &transHash, const uint256 &accountHash,
|
||||||
uint64 totCoins, uint32 closeTime, uint32 parentCloseTime, int closeFlags, int closeResolution,
|
uint64 totCoins, uint32 closeTime, uint32 parentCloseTime, int closeFlags, int closeResolution,
|
||||||
uint32 ledgerSeq); // used for database ledgers
|
uint32 ledgerSeq, bool& loaded); // used for database ledgers
|
||||||
|
|
||||||
Ledger(const std::vector<unsigned char>& rawLedger, bool hasPrefix);
|
Ledger(const std::vector<unsigned char>& rawLedger, bool hasPrefix);
|
||||||
Ledger(const std::string& rawLedger, bool hasPrefix);
|
Ledger(const std::string& rawLedger, bool hasPrefix);
|
||||||
|
|||||||
Reference in New Issue
Block a user