mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Startup and shutdown improvements. Performance improvements.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user