From ae8bfd12daa802d20791e69d3477e799d2b99f45 Mon Sep 17 00:00:00 2001 From: Pieter Wuille Date: Fri, 6 Jul 2012 16:33:34 +0200 Subject: 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. --- src/db.h | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'src/db.h') 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 &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) */ -- cgit v1.2.3