aboutsummaryrefslogtreecommitdiff
path: root/src/main.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/main.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/main.h')
-rw-r--r--src/main.h30
1 files changed, 10 insertions, 20 deletions
diff --git a/src/main.h b/src/main.h
index a57fadac78..0ec68b612b 100644
--- a/src/main.h
+++ b/src/main.h
@@ -583,7 +583,7 @@ public:
bool CheckTransaction() const;
// Try to accept this transaction into the memory pool
- bool AcceptToMemoryPool(CCoinsDB& coinsdb, bool fCheckInputs=true, bool* pfMissingInputs=NULL);
+ bool AcceptToMemoryPool(bool fCheckInputs=true, bool* pfMissingInputs=NULL);
protected:
static CTxOut GetOutputFor(const CTxIn& input, CCoinsView& mapInputs);
@@ -682,6 +682,7 @@ public:
bool WriteToDisk(CDiskBlockPos &pos)
{
+
// Open history file to append
CAutoFile fileout = CAutoFile(OpenUndoFile(pos), SER_DISK, CLIENT_VERSION);
if (!fileout)
@@ -995,8 +996,7 @@ public:
int GetDepthInMainChain() const { CBlockIndex *pindexRet; return GetDepthInMainChain(pindexRet); }
bool IsInMainChain() const { return GetDepthInMainChain() > 0; }
int GetBlocksToMaturity() const;
- bool AcceptToMemoryPool(CCoinsDB& coinsdb, bool fCheckInputs=true);
- bool AcceptToMemoryPool();
+ bool AcceptToMemoryPool(bool fCheckInputs=true);
};
@@ -1676,8 +1676,7 @@ public:
std::map<uint256, CTransaction> mapTx;
std::map<COutPoint, CInPoint> mapNextTx;
- bool accept(CCoinsDB& coinsdb, CTransaction &tx,
- bool fCheckInputs, bool* pfMissingInputs);
+ bool accept(CTransaction &tx, bool fCheckInputs, bool* pfMissingInputs);
bool addUnchecked(const uint256& hash, CTransaction &tx);
bool remove(CTransaction &tx);
void clear();
@@ -1722,6 +1721,7 @@ public:
// Modify the currently active block index
virtual bool SetBestBlock(CBlockIndex *pindex);
+ virtual bool BatchWrite(const std::map<uint256, CCoins> &mapCoins, CBlockIndex *pindex);
};
/** CCoinsView backed by another CCoinsView */
@@ -1738,21 +1738,7 @@ public:
CBlockIndex *GetBestBlock();
bool SetBestBlock(CBlockIndex *pindex);
void SetBackend(CCoinsView &viewIn);
-};
-
-
-/** CCoinsView backed by a CCoinsDB */
-class CCoinsViewDB : public CCoinsView
-{
-protected:
- CCoinsDB &db;
-public:
- CCoinsViewDB(CCoinsDB &dbIn);
- 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);
};
/** CCoinsView that adds a memory cache for transactions to another CCoinsView */
@@ -1769,7 +1755,9 @@ public:
bool HaveCoins(uint256 txid);
CBlockIndex *GetBestBlock();
bool SetBestBlock(CBlockIndex *pindex);
+ bool BatchWrite(const std::map<uint256, CCoins> &mapCoins, CBlockIndex *pindex);
bool Flush();
+ unsigned int GetCacheSize();
};
/** CCoinsView that brings transactions from a memorypool into view.
@@ -1785,4 +1773,6 @@ public:
bool HaveCoins(uint256 txid);
};
+extern CCoinsViewCache *pcoinsTip;
+
#endif