mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-27 14:35:52 +00:00
Fix a bug where a cached copy of a txn might not have a reference to the ledger
it was applied in, causing commands like 'tx' not to return metadata.
This commit is contained in:
@@ -451,9 +451,11 @@ void Ledger::saveAcceptedLedger(bool fromConsensus, LoadEvent::pointer event)
|
|||||||
std::string escMeta(sqlEscape(rawMeta.peekData()));
|
std::string escMeta(sqlEscape(rawMeta.peekData()));
|
||||||
|
|
||||||
SerializerIterator txnIt(rawTxn);
|
SerializerIterator txnIt(rawTxn);
|
||||||
|
|
||||||
SerializedTransaction txn(txnIt);
|
SerializedTransaction txn(txnIt);
|
||||||
assert(txn.getTransactionID() == item->getTag());
|
assert(txn.getTransactionID() == item->getTag());
|
||||||
TransactionMetaSet meta(item->getTag(), mLedgerSeq, rawMeta.peekData());
|
TransactionMetaSet meta(item->getTag(), mLedgerSeq, rawMeta.peekData());
|
||||||
|
theApp->getMasterTransaction().inLedger(item->getTag(), mLedgerSeq);
|
||||||
|
|
||||||
// Make sure transaction is in AccountTransactions.
|
// Make sure transaction is in AccountTransactions.
|
||||||
if (!SQL_EXISTS(db, boost::str(AcctTransExists % item->getTag().GetHex())))
|
if (!SQL_EXISTS(db, boost::str(AcctTransExists % item->getTag().GetHex())))
|
||||||
|
|||||||
@@ -18,13 +18,24 @@ TransactionMaster::TransactionMaster() : mCache("TransactionCache", CACHED_TRANS
|
|||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool TransactionMaster::inLedger(const uint256& hash, uint32 ledger)
|
||||||
|
{
|
||||||
|
Transaction::pointer txn = mCache.fetch(hash);
|
||||||
|
if (!txn)
|
||||||
|
return false;
|
||||||
|
txn->setStatus(COMMITTED, ledger);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
Transaction::pointer TransactionMaster::fetch(const uint256& txnID, bool checkDisk)
|
Transaction::pointer TransactionMaster::fetch(const uint256& txnID, bool checkDisk)
|
||||||
{
|
{
|
||||||
Transaction::pointer txn = mCache.fetch(txnID);
|
Transaction::pointer txn = mCache.fetch(txnID);
|
||||||
if (!checkDisk || txn) return txn;
|
if (!checkDisk || txn)
|
||||||
|
return txn;
|
||||||
|
|
||||||
txn = Transaction::load(txnID);
|
txn = Transaction::load(txnID);
|
||||||
if (!txn) return txn;
|
if (!txn)
|
||||||
|
return txn;
|
||||||
|
|
||||||
mCache.canonicalize(txnID, txn);
|
mCache.canonicalize(txnID, txn);
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ public:
|
|||||||
bool checkDisk, uint32 uCommitLedger);
|
bool checkDisk, uint32 uCommitLedger);
|
||||||
|
|
||||||
// return value: true = we had the transaction already
|
// return value: true = we had the transaction already
|
||||||
|
bool inLedger(const uint256& hash, uint32 ledger);
|
||||||
bool canonicalize(Transaction::pointer& txn, bool maybeNew);
|
bool canonicalize(Transaction::pointer& txn, bool maybeNew);
|
||||||
void sweep(void) { mCache.sweep(); }
|
void sweep(void) { mCache.sweep(); }
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user