aboutsummaryrefslogtreecommitdiff
path: root/src/db.h
diff options
context:
space:
mode:
authorPieter Wuille <pieter.wuille@gmail.com>2012-07-06 16:33:34 +0200
committerPieter Wuille <pieter.wuille@gmail.com>2012-10-20 23:08:57 +0200
commitae8bfd12daa802d20791e69d3477e799d2b99f45 (patch)
tree848867135da5954b7155ebe98c09db66d09d5737 /src/db.h
parent450cbb0944cd20a06ce806e6679a1f4c83c50db2 (diff)
Batch block connection during IBD
During the initial block download (or -loadblock), delay connection of new blocks a bit, and perform them in a single action. This reduces the load on the database engine, as subsequent blocks often update an earlier block's transaction already.
Diffstat (limited to 'src/db.h')
-rw-r--r--src/db.h20
1 files changed, 19 insertions, 1 deletions
diff --git a/src/db.h b/src/db.h
index dd8993d56d..bdab635468 100644
--- a/src/db.h
+++ b/src/db.h
@@ -102,6 +102,7 @@ protected:
explicit CDB(const char* pszFile, const char* pszMode="r+");
~CDB() { Close(); }
public:
+ void Flush();
void Close();
private:
CDB(const CDB&);
@@ -330,6 +331,23 @@ public:
bool WriteHashBestChain(uint256 hashBestChain);
};
+
+/** CCoinsView backed by a CCoinsDB */
+class CCoinsViewDB : public CCoinsView
+{
+protected:
+ CCoinsDB db;
+public:
+ CCoinsViewDB();
+ bool GetCoins(uint256 txid, CCoins &coins);
+ bool SetCoins(uint256 txid, const CCoins &coins);
+ bool HaveCoins(uint256 txid);
+ CBlockIndex *GetBestBlock();
+ bool SetBestBlock(CBlockIndex *pindex);
+ bool BatchWrite(const std::map<uint256, CCoins> &mapCoins, CBlockIndex *pindex);
+};
+
+
/** Access to the block database (chain.dat) */
class CChainDB : public CDB
{
@@ -350,7 +368,7 @@ public:
};
-bool LoadBlockIndex(CCoinsDB &coinsdb, CChainDB &chaindb);
+bool LoadBlockIndex(CChainDB &chaindb);
/** Access to the (IP) address database (peers.dat) */