aboutsummaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
authorJeff Garzik <jeff@garzik.org>2012-04-13 17:48:15 -0400
committerJeff Garzik <jgarzik@redhat.com>2012-04-13 17:48:15 -0400
commit9925d34a496b1d61a7d9976a385aa8122b1a4778 (patch)
tree1e18e8afcbffd964eab7e633937aad746c12e1c7 /src/main.cpp
parent6b8e7eefccf8d27c145d2e694037c2e10984f748 (diff)
Database micro-optimization for "tx" network message
Open database once per "tx" message, rather than multiple times, in the case of orphan transaction presence. As a side effect, a now-unused CTransaction::AcceptToMemoryPool() variant is removed.
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp11
1 files changed, 3 insertions, 8 deletions
diff --git a/src/main.cpp b/src/main.cpp
index bdafae8eb8..a6393a5c83 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -592,12 +592,6 @@ bool CTransaction::AcceptToMemoryPool(CTxDB& txdb, bool fCheckInputs, bool* pfMi
return true;
}
-bool CTransaction::AcceptToMemoryPool(bool fCheckInputs, bool* pfMissingInputs)
-{
- CTxDB txdb("r");
- return AcceptToMemoryPool(txdb, fCheckInputs, pfMissingInputs);
-}
-
uint64 nPooledTx = 0;
bool CTransaction::AddToMemoryPoolUnchecked()
@@ -2522,6 +2516,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
{
vector<uint256> vWorkQueue;
CDataStream vMsg(vRecv);
+ CTxDB txdb("r");
CTransaction tx;
vRecv >> tx;
@@ -2529,7 +2524,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
pfrom->AddInventoryKnown(inv);
bool fMissingInputs = false;
- if (tx.AcceptToMemoryPool(true, &fMissingInputs))
+ if (tx.AcceptToMemoryPool(txdb, true, &fMissingInputs))
{
SyncWithWallets(tx, NULL, true);
RelayMessage(inv, vMsg);
@@ -2549,7 +2544,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
CDataStream(vMsg) >> tx;
CInv inv(MSG_TX, tx.GetHash());
- if (tx.AcceptToMemoryPool(true))
+ if (tx.AcceptToMemoryPool(txdb, true))
{
printf(" accepted orphan tx %s\n", inv.hash.ToString().substr(0,10).c_str());
SyncWithWallets(tx, NULL, true);