Add OpenLedger::empty

This commit is contained in:
Vinnie Falco
2015-07-14 12:21:02 -07:00
parent 84161b86c7
commit 0627d3487b
2 changed files with 24 additions and 0 deletions

View File

@@ -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:

View File

@@ -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
{