mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Fix the 'getAccountHash() == mAccountStateMap->getHash()' bug.
'getNeededHashes' can do the wrong thing (report no needed hashes when we need them all) if we have a ledger's root node but not the root node of the tree we're querying.
This commit is contained in:
@@ -1614,6 +1614,32 @@ uint64 Ledger::scaleFeeLoad(uint64 fee)
|
||||
return theApp->getFeeTrack().scaleFeeLoad(fee, mBaseFee, mReferenceFeeUnits);
|
||||
}
|
||||
|
||||
std::vector<uint256> Ledger::getNeededTransactionHashes(int max)
|
||||
{
|
||||
std::vector<uint256> ret;
|
||||
if (mTransHash.isNonZero())
|
||||
{
|
||||
if (mTransactionMap->getHash().isZero())
|
||||
ret.push_back(mTransHash);
|
||||
else
|
||||
ret = mTransactionMap->getNeededHashes(max);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::vector<uint256> Ledger::getNeededAccountStateHashes(int max)
|
||||
{
|
||||
std::vector<uint256> ret;
|
||||
if (mAccountHash.isNonZero())
|
||||
{
|
||||
if (mAccountStateMap->getHash().isZero())
|
||||
ret.push_back(mAccountHash);
|
||||
else
|
||||
ret = mAccountStateMap->getNeededHashes(max);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE(quality)
|
||||
|
||||
BOOST_AUTO_TEST_CASE( getquality )
|
||||
|
||||
@@ -222,6 +222,9 @@ public:
|
||||
static uint256 getLedgerFeatureIndex();
|
||||
static uint256 getLedgerFeeIndex();
|
||||
|
||||
std::vector<uint256> getNeededTransactionHashes(int max);
|
||||
std::vector<uint256> getNeededAccountStateHashes(int max);
|
||||
|
||||
// index calculation functions
|
||||
static uint256 getAccountRootIndex(const uint160& uAccountID);
|
||||
|
||||
|
||||
@@ -139,7 +139,7 @@ bool LedgerAcquire::tryLocal()
|
||||
{
|
||||
mLedger->peekTransactionMap()->fetchRoot(mLedger->getTransHash());
|
||||
cLog(lsDEBUG) << "Got root txn map locally";
|
||||
std::vector<uint256> h = mLedger->peekTransactionMap()->getNeededHashes(1);
|
||||
std::vector<uint256> h = mLedger->getNeededTransactionHashes(1);
|
||||
if (h.empty())
|
||||
{
|
||||
cLog(lsDEBUG) << "Had full txn map locally";
|
||||
@@ -155,14 +155,17 @@ bool LedgerAcquire::tryLocal()
|
||||
if (!mHaveState)
|
||||
{
|
||||
if (mLedger->getAccountHash().isZero())
|
||||
{
|
||||
cLog(lsFATAL) << "We are acquiring a ledger with a zero account hash";
|
||||
mHaveState = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
mLedger->peekAccountStateMap()->fetchRoot(mLedger->getAccountHash());
|
||||
cLog(lsDEBUG) << "Got root AS map locally";
|
||||
std::vector<uint256> h = mLedger->peekAccountStateMap()->getNeededHashes(1);
|
||||
std::vector<uint256> h = mLedger->getNeededAccountStateHashes(1);
|
||||
if (h.empty())
|
||||
{
|
||||
cLog(lsDEBUG) << "Had full AS map locally";
|
||||
@@ -783,13 +786,13 @@ std::vector<LedgerAcquire::neededHash_t> LedgerAcquire::getNeededHashes()
|
||||
}
|
||||
if (!mHaveState)
|
||||
{
|
||||
std::vector<uint256> v = mLedger->peekAccountStateMap()->getNeededHashes(16);
|
||||
std::vector<uint256> v = mLedger->getNeededAccountStateHashes(16);
|
||||
BOOST_FOREACH(const uint256& h, v)
|
||||
ret.push_back(std::make_pair(ripple::TMGetObjectByHash::otSTATE_NODE, h));
|
||||
}
|
||||
if (!mHaveTransactions)
|
||||
{
|
||||
std::vector<uint256> v = mLedger->peekTransactionMap()->getNeededHashes(16);
|
||||
std::vector<uint256> v = mLedger->getNeededAccountStateHashes(16);
|
||||
BOOST_FOREACH(const uint256& h, v)
|
||||
ret.push_back(std::make_pair(ripple::TMGetObjectByHash::otTRANSACTION_NODE, h));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user