Startup and shutdown improvements. Performance improvements.

This commit is contained in:
JoelKatz
2013-03-03 02:09:19 -08:00
parent 0015716cb5
commit 51a85504a8
7 changed files with 70 additions and 10 deletions

View File

@@ -781,6 +781,45 @@ bool Ledger::getHashesByIndex(uint32 ledgerIndex, uint256& ledgerHash, uint256&
#endif
}
std::map< uint32, std::pair<uint256, uint256> > Ledger::getHashesByIndex(uint32 minSeq, uint32 maxSeq)
{
#ifndef NO_SQLITE_PREPARE
std::map< uint32, std::pair<uint256, uint256> > ret;
DatabaseCon *con = theApp->getLedgerDB();
ScopedLock sl(con->getDBLock());
static SqliteStatement pSt(con->getDB()->getSqliteDB(),
"SELECT LedgerSeq,LedgerHash,PrevHash FROM Ledgers INDEXED BY SeqLedger "
"WHERE LedgerSeq >= ? AND LedgerSeq <= ?;");
std::pair<uint256, uint256> hashes;
pSt.bind(1, minSeq);
pSt.bind(2, maxSeq);
do
{
int r = pSt.step();
if (pSt.isDone(r))
{
pSt.reset();
return ret;
}
if (!pSt.isRow(r))
{
pSt.reset();
return ret;
}
hashes.first.SetHex(pSt.peekString(1), true);
hashes.second.SetHex(pSt.peekString(2), true);
ret[pSt.getUInt32(0)] = hashes;
} while(1);
#else
#error SQLite prepare is required
#endif
}
Ledger::pointer Ledger::getLastFullLedger()
{
try