Fix OpenLedger::empty:

* Fix logic of OpenLedger::empty
* Add regression test
* Remove some dead code
This commit is contained in:
JoelKatz
2015-09-24 21:37:43 -07:00
committed by Vinnie Falco
parent 92b2ca70b7
commit d6875975ab
3 changed files with 11 additions and 7 deletions

View File

@@ -1132,12 +1132,6 @@ void LedgerConsensusImp::accept (std::shared_ptr<SHAMap> set)
// See if we can accept a ledger as fully-validated
ledgerMaster_.consensusBuilt (newLCL);
// Build new open ledger
auto newOL = std::make_shared<Ledger>(
open_ledger, *newLCL, app_.timeKeeper().closeTime());
OpenView accum(&*newOL);
assert(accum.open());
// Apply disputed transactions that didn't get in
//
// The first crack of transactions to get into the new
@@ -1177,6 +1171,8 @@ void LedgerConsensusImp::accept (std::shared_ptr<SHAMap> set)
}
{
// Build new open ledger
auto lock = beast::make_lock(
app_.getMasterMutex(), std::defer_lock);
LedgerMaster::ScopedLockType sl (

View File

@@ -41,7 +41,7 @@ OpenLedger::empty() const
{
std::lock_guard<
std::mutex> lock(modify_mutex_);
return current_->txCount() != 0;
return current_->txCount() == 0;
}
std::shared_ptr<ReadView const>

View File

@@ -551,6 +551,14 @@ class View_test
}
expect(! v1.exists(k(1)));
}
// Make sure OpenLedger::empty works
{
Env env(*this);
expect(env.openLedger.empty());
env.fund(XRP(10000), Account("test"));
expect(!env.openLedger.empty());
}
}
void run()