From 65395ea971a52c85e1a72382836f7e4f4e1ca092 Mon Sep 17 00:00:00 2001 From: JoelKatz Date: Mon, 15 Oct 2012 03:48:45 -0700 Subject: [PATCH] Add some sanity checks. --- src/Application.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Application.cpp b/src/Application.cpp index 72fe6ca1b..59f80e2e4 100644 --- a/src/Application.cpp +++ b/src/Application.cpp @@ -222,12 +222,22 @@ void Application::loadOldLedger() cLog(lsINFO) << "Loading ledger " << lastLedger->getHash() << " seq:" << lastLedger->getLedgerSeq(); + if (lastLedger->getAccountHash().isZero()) + { + cLog(lsFATAL) << "Ledger is empty."; + assert(false); + exit(-1); + } + if (!lastLedger->walkLedger()) { cLog(lsFATAL) << "Ledger is missing nodes."; exit(-1); } + assert(lastLedger->getAccountHash() == lastLedger->peekAccountStateMap()->getHash()); + assert(lastLedger->getTransHash() == lastLedger->peekTransactionMap()->getHash()); + Ledger::pointer openLedger = boost::make_shared(false, boost::ref(*lastLedger)); mMasterLedger.switchLedgers(lastLedger, openLedger); mNetOps.setLastCloseTime(lastLedger->getCloseTimeNC());