Skip to content

Commit 722fa28

Browse files
committed
Break dependency of init on wallet.
This required some code movement (what was CWalletTx::AcceptToMemoryPool doing in main?), and adding a few explicit includes that used to be implicit through init.h.
1 parent 00588c3 commit 722fa28

File tree

7 files changed

+32
-22
lines changed

7 files changed

+32
-22
lines changed

src/bitcoind.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
// Distributed under the MIT/X11 software license, see the accompanying
44
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
55

6+
#include "ui_interface.h"
67
#include "init.h"
8+
#include "util.h"
9+
#include "main.h"
710
#include "bitcoinrpc.h"
811
#include <boost/algorithm/string/predicate.hpp>
912

src/bitcoinrpc.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
55

66
#include "chainparams.h"
7+
#include "main.h"
8+
#include "wallet.h"
79
#include "init.h"
810
#include "util.h"
911
#include "sync.h"

src/init.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@
55
#ifndef BITCOIN_INIT_H
66
#define BITCOIN_INIT_H
77

8-
#include "wallet.h"
8+
#include <string>
9+
#include <boost/thread.hpp>
10+
11+
class CWallet;
912

1013
extern std::string strWalletFile;
1114
extern CWallet* pwalletMain;

src/main.cpp

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1054,27 +1054,6 @@ bool CMerkleTx::AcceptToMemoryPool(bool fLimitFree)
10541054
}
10551055

10561056

1057-
1058-
bool CWalletTx::AcceptWalletTransaction()
1059-
{
1060-
{
1061-
LOCK(mempool.cs);
1062-
// Add previous supporting transactions first
1063-
BOOST_FOREACH(CMerkleTx& tx, vtxPrev)
1064-
{
1065-
if (!tx.IsCoinBase())
1066-
{
1067-
uint256 hash = tx.GetHash();
1068-
if (!mempool.exists(hash) && pcoinsTip->HaveCoins(hash))
1069-
tx.AcceptToMemoryPool(false);
1070-
}
1071-
}
1072-
return AcceptToMemoryPool(false);
1073-
}
1074-
return false;
1075-
}
1076-
1077-
10781057
// Return transaction in tx, and if it was found inside a block, its hash is placed in hashBlock
10791058
bool GetTransaction(const uint256 &hash, CTransaction &txOut, uint256 &hashBlock, bool fAllowSlow)
10801059
{

src/qt/optionsmodel.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66

77
#include "bitcoinunits.h"
88
#include "init.h"
9+
#include "core.h"
10+
#include "wallet.h"
11+
#include "netbase.h"
912
#include "walletdb.h"
1013
#include "guiutil.h"
1114

src/rpcdump.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include <fstream>
77

88
#include "init.h" // for pwalletMain
9+
#include "wallet.h"
910
#include "bitcoinrpc.h"
1011
#include "ui_interface.h"
1112
#include "base58.h"

src/wallet.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -777,6 +777,25 @@ void CWalletTx::AddSupportingTransactions()
777777
reverse(vtxPrev.begin(), vtxPrev.end());
778778
}
779779

780+
bool CWalletTx::AcceptWalletTransaction()
781+
{
782+
{
783+
LOCK(mempool.cs);
784+
// Add previous supporting transactions first
785+
BOOST_FOREACH(CMerkleTx& tx, vtxPrev)
786+
{
787+
if (!tx.IsCoinBase())
788+
{
789+
uint256 hash = tx.GetHash();
790+
if (!mempool.exists(hash) && pcoinsTip->HaveCoins(hash))
791+
tx.AcceptToMemoryPool(false);
792+
}
793+
}
794+
return AcceptToMemoryPool(false);
795+
}
796+
return false;
797+
}
798+
780799
bool CWalletTx::WriteToDisk()
781800
{
782801
return CWalletDB(pwallet->strWalletFile).WriteTx(GetHash(), *this);

0 commit comments

Comments
 (0)