I have an STTx
and a Ledger
. How can I get a new Ledger
with the transaction applied (or even just a ReadView
such that .info().accountHash
is up-to-date)?
Asked
Active
Viewed 67 times
0

John Freeman
- 2,552
- 1
- 27
- 34
1 Answers
0
# include <ripple/app/ledger/BuildLedger.h>
# include <ripple/app/misc/CanonicalTXSet.h>
# include <ripple/consensus/LedgerTiming.h> // ledgerDefaultTimeResolution
// Start with what you have.
Application const& app = ...
beast::Journal journal = ...
std::shared_ptr<Ledger const> const& parent = ...
std::shared_ptr<STTx const> const& transaction = ...
// Massage them into parameters for buildLedger.
NetClock::time_point const closeTime = app.timeKeeper().closeTime();
bool const closeTimeCorrect = false;
NetClock::duration closeTimeResolution = ledgerDefaultTimeResolution;
CanonicalTXSet const transactions{parent->info().hash};
transactions.insert(transaction);
std::set<TXID> failedTransactions; // Leave empty.
std::shared_ptr<Ledger> child = buildLedger(
parent,
closeTime,
closeTimeCorrect ,
closeTimeResolution,
app,
transactions,
failedTransactions,
journal);

John Freeman
- 2,552
- 1
- 27
- 34