aboutsummaryrefslogtreecommitdiff
path: root/src/txdb.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/txdb.cpp')
-rw-r--r--src/txdb.cpp29
1 files changed, 14 insertions, 15 deletions
diff --git a/src/txdb.cpp b/src/txdb.cpp
index 0731d843f3..bb108f38ba 100644
--- a/src/txdb.cpp
+++ b/src/txdb.cpp
@@ -66,23 +66,10 @@ bool CCoinsViewDB::BatchWrite(CCoinsMap &mapCoins, const uint256 &hashBlock) {
CBlockTreeDB::CBlockTreeDB(size_t nCacheSize, bool fMemory, bool fWipe) : CLevelDBWrapper(GetDataDir() / "blocks" / "index", nCacheSize, fMemory, fWipe) {
}
-bool CBlockTreeDB::WriteBlockIndex(const CDiskBlockIndex& blockindex)
-{
- return Write(make_pair('b', blockindex.GetBlockHash()), blockindex);
-}
-
-bool CBlockTreeDB::WriteBlockFileInfo(int nFile, const CBlockFileInfo &info) {
- return Write(make_pair('f', nFile), info);
-}
-
bool CBlockTreeDB::ReadBlockFileInfo(int nFile, CBlockFileInfo &info) {
return Read(make_pair('f', nFile), info);
}
-bool CBlockTreeDB::WriteLastBlockFile(int nFile) {
- return Write('l', nFile);
-}
-
bool CBlockTreeDB::WriteReindexing(bool fReindexing) {
if (fReindexing)
return Write('R', '1');
@@ -142,7 +129,7 @@ bool CCoinsViewDB::GetStats(CCoinsStats &stats) const {
ss << VARINT(0);
}
pcursor->Next();
- } catch (std::exception &e) {
+ } catch (const std::exception& e) {
return error("%s : Deserialize or I/O error - %s", __func__, e.what());
}
}
@@ -152,6 +139,18 @@ bool CCoinsViewDB::GetStats(CCoinsStats &stats) const {
return true;
}
+bool CBlockTreeDB::WriteBatchSync(const std::vector<std::pair<int, const CBlockFileInfo*> >& fileInfo, int nLastFile, const std::vector<const CBlockIndex*>& blockinfo) {
+ CLevelDBBatch batch;
+ for (std::vector<std::pair<int, const CBlockFileInfo*> >::const_iterator it=fileInfo.begin(); it != fileInfo.end(); it++) {
+ batch.Write(make_pair('f', it->first), *it->second);
+ }
+ batch.Write('l', nLastFile);
+ for (std::vector<const CBlockIndex*>::const_iterator it=blockinfo.begin(); it != blockinfo.end(); it++) {
+ batch.Write(make_pair('b', (*it)->GetBlockHash()), CDiskBlockIndex(*it));
+ }
+ return WriteBatch(batch, true);
+}
+
bool CBlockTreeDB::ReadTxIndex(const uint256 &txid, CDiskTxPos &pos) {
return Read(make_pair('t', txid), pos);
}
@@ -219,7 +218,7 @@ bool CBlockTreeDB::LoadBlockIndexGuts()
} else {
break; // if shutdown requested or finished loading block index
}
- } catch (std::exception &e) {
+ } catch (const std::exception& e) {
return error("%s : Deserialize or I/O error - %s", __func__, e.what());
}
}