mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Add OpenLedger::empty
This commit is contained in:
@@ -73,6 +73,22 @@ public:
|
||||
Config const& config, CachedSLEs& cache,
|
||||
beast::Journal journal);
|
||||
|
||||
/** 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.
|
||||
|
||||
@note The value returned is only meaningful for
|
||||
that specific instant in time. An open,
|
||||
empty ledger can become non empty from
|
||||
subsequent modifications. Caller is
|
||||
responsible for synchronizing the meaning of
|
||||
the return value.
|
||||
*/
|
||||
bool
|
||||
empty() const;
|
||||
|
||||
/** Returns a view to the current open ledger.
|
||||
|
||||
Thread safety:
|
||||
|
||||
@@ -36,6 +36,14 @@ OpenLedger::OpenLedger(std::shared_ptr<
|
||||
{
|
||||
}
|
||||
|
||||
bool
|
||||
OpenLedger::empty() const
|
||||
{
|
||||
std::lock_guard<
|
||||
std::mutex> lock(modify_mutex_);
|
||||
return current_->txCount() != 0;
|
||||
}
|
||||
|
||||
std::shared_ptr<ReadView const>
|
||||
OpenLedger::current() const
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user