rippled
|
Represents the open ledger. More...
Public Types | |
using | modify_type = std::function< bool(OpenView &, beast::Journal)> |
Signature for modification functions. More... | |
Public Member Functions | |
OpenLedger ()=delete | |
OpenLedger (OpenLedger const &)=delete | |
OpenLedger & | operator= (OpenLedger const &)=delete |
OpenLedger (std::shared_ptr< Ledger const > const &ledger, CachedSLEs &cache, beast::Journal journal) | |
Create a new open ledger object. More... | |
bool | empty () const |
Returns true if there are no transactions. More... | |
std::shared_ptr< OpenView const > | current () const |
Returns a view to the current open ledger. More... | |
bool | modify (modify_type const &f) |
Modify the open ledger. More... | |
void | accept (Application &app, Rules const &rules, std::shared_ptr< Ledger const > const &ledger, OrderedTxs const &locals, bool retriesFirst, OrderedTxs &retries, ApplyFlags flags, std::string const &suffix="", modify_type const &f={}) |
Accept a new ledger. More... | |
Private Types | |
enum | Result { success, failure, retry } |
Private Member Functions | |
std::shared_ptr< OpenView > | create (Rules const &rules, std::shared_ptr< Ledger const > const &ledger) |
Static Private Member Functions | |
template<class FwdRange > | |
static void | apply (Application &app, OpenView &view, ReadView const &check, FwdRange const &txs, OrderedTxs &retries, ApplyFlags flags, beast::Journal j) |
Algorithm for applying transactions. More... | |
static Result | apply_one (Application &app, OpenView &view, std::shared_ptr< STTx const > const &tx, bool retry, ApplyFlags flags, beast::Journal j) |
Private Attributes | |
const beast::Journal | j_ |
CachedSLEs & | cache_ |
std::mutex | modify_mutex_ |
std::mutex | current_mutex_ |
std::shared_ptr< OpenView const > | current_ |
Represents the open ledger.
Definition at line 49 of file OpenLedger.h.
using ripple::OpenLedger::modify_type = std::function<bool(OpenView&, beast::Journal)> |
Signature for modification functions.
The modification function is called during apply and modify with an OpenView to accumulate changes and the Journal to use for logging.
A return value of true
informs OpenLedger that changes were made. Always returning true
won't cause harm, but it may be sub-optimal.
Definition at line 70 of file OpenLedger.h.
|
private |
Enumerator | |
---|---|
success | |
failure | |
retry |
Definition at line 190 of file OpenLedger.h.
|
delete |
|
delete |
|
explicit |
Create a new open ledger object.
ledger | A closed ledger |
Definition at line 34 of file OpenLedger.cpp.
|
delete |
bool ripple::OpenLedger::empty | ( | ) | const |
Returns true
if there are no transactions.
The behavior of ledger closing can be different depending on whether or not transactions exist in the open ledger.
Definition at line 43 of file OpenLedger.cpp.
std::shared_ptr< OpenView const > ripple::OpenLedger::current | ( | ) | const |
Returns a view to the current open ledger.
Thread safety: Can be called concurrently from any thread.
Effects: The caller is given ownership of a non-modifiable snapshot of the open ledger at the time of the call.
Definition at line 50 of file OpenLedger.cpp.
bool ripple::OpenLedger::modify | ( | modify_type const & | f | ) |
Modify the open ledger.
Thread safety: Can be called concurrently from any thread.
If f
returns true
, the changes made in the OpenView will be published to the open ledger.
true
if the open view was changed Definition at line 57 of file OpenLedger.cpp.
void ripple::OpenLedger::accept | ( | Application & | app, |
Rules const & | rules, | ||
std::shared_ptr< Ledger const > const & | ledger, | ||
OrderedTxs const & | locals, | ||
bool | retriesFirst, | ||
OrderedTxs & | retries, | ||
ApplyFlags | flags, | ||
std::string const & | suffix = "" , |
||
modify_type const & | f = {} |
||
) |
Accept a new ledger.
Thread safety: Can be called concurrently from any thread.
Effects:
A new open view based on the accepted ledger is created, and the list of retriable transactions is optionally applied first depending on the value of `retriesFirst`. The transactions in the current open view are applied to the new open view. The list of local transactions are applied to the new open view. The optional modify function f is called to perform further modifications to the open view, atomically. Changes made in the modify function are not visible to callers until accept() returns. Any failed, retriable transactions are left in `retries` for the caller. The current view is atomically set to the new open view.
rules | The rules for the open ledger |
ledger | A new closed ledger |
Definition at line 71 of file OpenLedger.cpp.
|
staticprivate |
Algorithm for applying transactions.
This has the retry logic and ordering semantics used for consensus and building the open ledger.
Definition at line 209 of file OpenLedger.h.
|
private |
Definition at line 147 of file OpenLedger.cpp.
|
staticprivate |
Definition at line 158 of file OpenLedger.cpp.
|
private |
Definition at line 52 of file OpenLedger.h.
|
private |
Definition at line 53 of file OpenLedger.h.
|
mutableprivate |
Definition at line 54 of file OpenLedger.h.
|
mutableprivate |
Definition at line 55 of file OpenLedger.h.
|
private |
Definition at line 56 of file OpenLedger.h.