aboutsummaryrefslogtreecommitdiff
path: root/src/txdb.cpp
diff options
context:
space:
mode:
authorPieter Wuille <pieter.wuille@gmail.com>2014-11-25 16:26:20 +0100
committerPieter Wuille <pieter.wuille@gmail.com>2014-11-25 16:26:35 +0100
commit63d1ae5556ea40dde0cca20addda4bba40005496 (patch)
tree84300b58849b139c71381704d54f640ffff694f7 /src/txdb.cpp
parentac0b2393a447bb20f8b0489a67237c98a1cfff4a (diff)
Do all block index writes in a batch
Diffstat (limited to 'src/txdb.cpp')
-rw-r--r--src/txdb.cpp25
1 files changed, 12 insertions, 13 deletions
diff --git a/src/txdb.cpp b/src/txdb.cpp
index 0731d843f3..29ef350374 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');
@@ -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);
}