mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-20 11:05:54 +00:00
first
This commit is contained in:
39
LedgerHistory.cpp
Normal file
39
LedgerHistory.cpp
Normal file
@@ -0,0 +1,39 @@
|
||||
#include "LedgerHistory.h"
|
||||
#include "Config.h"
|
||||
|
||||
/*
|
||||
Soon we should support saving the ledger in a real DB
|
||||
For now save them all in
|
||||
*/
|
||||
|
||||
void LedgerHistory::load()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool LedgerHistory::loadLedger(uint64 index)
|
||||
{
|
||||
Ledger::pointer ledger(new Ledger(index));
|
||||
if(ledger->load(theConfig.HISTORY_DIR))
|
||||
{
|
||||
mLedgers[index]=ledger;
|
||||
}
|
||||
return(false);
|
||||
}
|
||||
|
||||
// this will see if the ledger is in memory
|
||||
// if not it will check disk and load it
|
||||
// if not it will return NULL
|
||||
Ledger::pointer LedgerHistory::getLedger(uint64 index)
|
||||
{
|
||||
if(mLedgers.count(index))
|
||||
return(mLedgers[index]);
|
||||
if(loadLedger(index)) return(mLedgers[index]);
|
||||
return(Ledger::pointer());
|
||||
}
|
||||
|
||||
void LedgerHistory::addLedger(Ledger::pointer ledger)
|
||||
{
|
||||
mLedgers[ledger->getIndex()]=ledger;
|
||||
ledger->save(theConfig.HISTORY_DIR);
|
||||
}
|
||||
Reference in New Issue
Block a user