mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Make sure the ledger hash is up to date when we set the immutable flag.
This commit is contained in:
@@ -108,7 +108,7 @@ Ledger::Ledger(const std::string& rawLedger) : mCloseTime(0),
|
||||
|
||||
void Ledger::updateHash()
|
||||
{
|
||||
if(!mImmutable)
|
||||
if (!mImmutable)
|
||||
{
|
||||
if (mTransactionMap) mTransHash = mTransactionMap->getHash();
|
||||
else mTransHash.zero();
|
||||
@@ -235,7 +235,6 @@ uint256 Ledger::getHash()
|
||||
|
||||
void Ledger::saveAcceptedLedger(Ledger::pointer ledger)
|
||||
{
|
||||
|
||||
std::string sql="INSERT INTO Ledgers "
|
||||
"(LedgerHash,LedgerSeq,PrevHash,TotalCoins,ClosingTime,AccountSetHash,TransSetHash) VALUES ('";
|
||||
sql.append(ledger->getHash().GetHex());
|
||||
@@ -328,10 +327,9 @@ Ledger::pointer Ledger::getSQL(const std::string& sql)
|
||||
uint32 ledgerSeq;
|
||||
std::string hash;
|
||||
|
||||
if(1)
|
||||
{
|
||||
ScopedLock sl(theApp->getLedgerDB()->getDBLock());
|
||||
Database *db = theApp->getLedgerDB()->getDB();
|
||||
ScopedLock sl(theApp->getLedgerDB()->getDBLock());
|
||||
|
||||
if (!db->executeSQL(sql) || !db->startIterRows())
|
||||
return Ledger::pointer();
|
||||
@@ -350,7 +348,8 @@ Ledger::pointer Ledger::getSQL(const std::string& sql)
|
||||
db->endIterRows();
|
||||
}
|
||||
|
||||
Ledger::pointer ret=boost::make_shared<Ledger>(prevHash, transHash, accountHash, totCoins, closingTime, ledgerSeq);
|
||||
Ledger::pointer ret =
|
||||
boost::make_shared<Ledger>(prevHash, transHash, accountHash, totCoins, closingTime, ledgerSeq);
|
||||
if (ret->getHash() != ledgerHash)
|
||||
{
|
||||
assert(false);
|
||||
|
||||
@@ -96,7 +96,7 @@ public:
|
||||
void updateHash();
|
||||
void setClosed() { mClosed = true; }
|
||||
void setAccepted() { mAccepted = true; }
|
||||
void setImmutable() { mImmutable = true; }
|
||||
void setImmutable() { updateHash(); mImmutable = true; }
|
||||
bool isClosed() { return mClosed; }
|
||||
bool isAccepted() { return mAccepted; }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user