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/rpcrawtransaction.cpp | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) (limited to 'src/rpcrawtransaction.cpp') diff --git a/src/rpcrawtransaction.cpp b/src/rpcrawtransaction.cpp index c62898316c..647384f333 100644 --- a/src/rpcrawtransaction.cpp +++ b/src/rpcrawtransaction.cpp @@ -339,9 +339,8 @@ Value signrawtransaction(const Array& params, bool fHelp) CCoinsViewCache view(viewDummy); { LOCK(mempool.cs); - CCoinsDB coinsdb("r"); - CCoinsViewDB viewDB(coinsdb); - CCoinsViewMemPool viewMempool(viewDB, mempool); + CCoinsViewCache &viewChain = *pcoinsTip; + CCoinsViewMemPool viewMempool(viewChain, mempool); view.SetBackend(viewMempool); // temporarily switch cache backend to db+mempool view BOOST_FOREACH(const CTxIn& txin, mergedTx.vin) { @@ -350,7 +349,7 @@ Value signrawtransaction(const Array& params, bool fHelp) view.GetCoins(prevHash, coins); // this is certainly allowed to fail } - view.SetBackend(viewDummy); // switch back to avoid locking db/mempool too long + view.SetBackend(viewDummy); // switch back to avoid locking mempool for too long } // Add previous txouts given in the RPC call: @@ -502,17 +501,13 @@ Value sendrawtransaction(const Array& params, bool fHelp) uint256 hashTx = tx.GetHash(); bool fHave = false; + CCoinsViewCache &view = *pcoinsTip; CCoins existingCoins; { - CCoinsDB coinsdb("r"); - { - CCoinsViewDB coinsviewDB(coinsdb); - CCoinsViewMemPool coinsview(coinsviewDB, mempool); - fHave = coinsview.GetCoins(hashTx, existingCoins); - } + fHave = view.GetCoins(hashTx, existingCoins); if (!fHave) { // push to local node - if (!tx.AcceptToMemoryPool(coinsdb)) + if (!tx.AcceptToMemoryPool()) throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "TX rejected"); } } -- cgit v1.2.3