Add LevelDB MemEnv support

Support LevelDB memory-backed environments, and use them in unit tests.
This commit is contained in:
Pieter Wuille
2012-09-04 18:12:00 +02:00
parent 2d8a48292b
commit e1bfbab802
8 changed files with 27 additions and 12 deletions

View File

@@ -19,7 +19,7 @@ void static BatchWriteHashBestChain(CLevelDBBatch &batch, const uint256 &hash) {
batch.Write('B', hash);
}
CCoinsViewDB::CCoinsViewDB() : db(GetDataDir() / "coins") {
CCoinsViewDB::CCoinsViewDB(bool fMemory) : db(GetDataDir() / "coins", fMemory) {
}
bool CCoinsViewDB::GetCoins(uint256 txid, CCoins &coins) {
@@ -63,6 +63,9 @@ bool CCoinsViewDB::BatchWrite(const std::map<uint256, CCoins> &mapCoins, CBlockI
return db.WriteBatch(batch);
}
CBlockTreeDB::CBlockTreeDB(bool fMemory) : CLevelDB(GetDataDir() / "blktree", fMemory) {
}
bool CBlockTreeDB::WriteBlockIndex(const CDiskBlockIndex& blockindex)
{
return Write(make_pair('b', blockindex.GetBlockHash()), blockindex);