diff --git a/src/ripple/app/ledger/OpenLedger.h b/src/ripple/app/ledger/OpenLedger.h index 5989a2633..bbb9ca052 100644 --- a/src/ripple/app/ledger/OpenLedger.h +++ b/src/ripple/app/ledger/OpenLedger.h @@ -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: diff --git a/src/ripple/app/ledger/impl/OpenLedger.cpp b/src/ripple/app/ledger/impl/OpenLedger.cpp index 56dc2bf89..46b0c2ddb 100644 --- a/src/ripple/app/ledger/impl/OpenLedger.cpp +++ b/src/ripple/app/ledger/impl/OpenLedger.cpp @@ -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 OpenLedger::current() const {