void LedgerManagerImpl::closeLedgerHelper(LedgerDelta const& delta) { delta.markMeters(mApp); mApp.getBucketManager().addBatch(mApp, mCurrentLedger->mHeader.ledgerSeq, delta.getLiveEntries(), delta.getDeadEntries()); mApp.getBucketManager().snapshotLedger(mCurrentLedger->mHeader); mCurrentLedger->storeInsert(*this); mApp.getPersistentState().setState(PersistentState::kLastClosedLedger, binToHex(mCurrentLedger->getHash())); // Store the current HAS in the database; this is really just to checkpoint // the bucketlist so we can survive a restart and re-attach to the buckets. HistoryArchiveState has(mCurrentLedger->mHeader.ledgerSeq, mApp.getBucketManager().getBucketList()); // We almost always want to try to resolve completed merges to single // buckets, as it makes restarts less fragile: fewer saved/restored shadows, // fewer buckets for the user to accidentally delete from their buckets // dir. But we support the option of not-doing so, only for the sake of // testing. Note: this is nonblocking in any case. if (!mApp.getConfig().ARTIFICIALLY_PESSIMIZE_MERGES_FOR_TESTING) { has.resolveAnyReadyFutures(); } mApp.getPersistentState().setState(PersistentState::kHistoryArchiveState, has.toString()); advanceLedgerPointers(); }