Browse Source

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.
0.10
Pieter Wuille 11 years ago
parent
commit
722fa283d0
  1. 3
      src/bitcoind.cpp
  2. 2
      src/bitcoinrpc.cpp
  3. 5
      src/init.h
  4. 21
      src/main.cpp
  5. 3
      src/qt/optionsmodel.cpp
  6. 1
      src/rpcdump.cpp
  7. 19
      src/wallet.cpp

3
src/bitcoind.cpp

@ -3,7 +3,10 @@
// Distributed under the MIT/X11 software license, see the accompanying // Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php. // file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "ui_interface.h"
#include "init.h" #include "init.h"
#include "util.h"
#include "main.h"
#include "bitcoinrpc.h" #include "bitcoinrpc.h"
#include <boost/algorithm/string/predicate.hpp> #include <boost/algorithm/string/predicate.hpp>

2
src/bitcoinrpc.cpp

@ -4,6 +4,8 @@
// file COPYING or http://www.opensource.org/licenses/mit-license.php. // file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "chainparams.h" #include "chainparams.h"
#include "main.h"
#include "wallet.h"
#include "init.h" #include "init.h"
#include "util.h" #include "util.h"
#include "sync.h" #include "sync.h"

5
src/init.h

@ -5,7 +5,10 @@
#ifndef BITCOIN_INIT_H #ifndef BITCOIN_INIT_H
#define BITCOIN_INIT_H #define BITCOIN_INIT_H
#include "wallet.h" #include <string>
#include <boost/thread.hpp>
class CWallet;
extern std::string strWalletFile; extern std::string strWalletFile;
extern CWallet* pwalletMain; extern CWallet* pwalletMain;

21
src/main.cpp

@ -1054,27 +1054,6 @@ bool CMerkleTx::AcceptToMemoryPool(bool fLimitFree)
} }
bool CWalletTx::AcceptWalletTransaction()
{
{
LOCK(mempool.cs);
// Add previous supporting transactions first
BOOST_FOREACH(CMerkleTx& tx, vtxPrev)
{
if (!tx.IsCoinBase())
{
uint256 hash = tx.GetHash();
if (!mempool.exists(hash) && pcoinsTip->HaveCoins(hash))
tx.AcceptToMemoryPool(false);
}
}
return AcceptToMemoryPool(false);
}
return false;
}
// Return transaction in tx, and if it was found inside a block, its hash is placed in hashBlock // Return transaction in tx, and if it was found inside a block, its hash is placed in hashBlock
bool GetTransaction(const uint256 &hash, CTransaction &txOut, uint256 &hashBlock, bool fAllowSlow) bool GetTransaction(const uint256 &hash, CTransaction &txOut, uint256 &hashBlock, bool fAllowSlow)
{ {

3
src/qt/optionsmodel.cpp

@ -6,6 +6,9 @@
#include "bitcoinunits.h" #include "bitcoinunits.h"
#include "init.h" #include "init.h"
#include "core.h"
#include "wallet.h"
#include "netbase.h"
#include "walletdb.h" #include "walletdb.h"
#include "guiutil.h" #include "guiutil.h"

1
src/rpcdump.cpp

@ -6,6 +6,7 @@
#include <fstream> #include <fstream>
#include "init.h" // for pwalletMain #include "init.h" // for pwalletMain
#include "wallet.h"
#include "bitcoinrpc.h" #include "bitcoinrpc.h"
#include "ui_interface.h" #include "ui_interface.h"
#include "base58.h" #include "base58.h"

19
src/wallet.cpp

@ -777,6 +777,25 @@ void CWalletTx::AddSupportingTransactions()
reverse(vtxPrev.begin(), vtxPrev.end()); reverse(vtxPrev.begin(), vtxPrev.end());
} }
bool CWalletTx::AcceptWalletTransaction()
{
{
LOCK(mempool.cs);
// Add previous supporting transactions first
BOOST_FOREACH(CMerkleTx& tx, vtxPrev)
{
if (!tx.IsCoinBase())
{
uint256 hash = tx.GetHash();
if (!mempool.exists(hash) && pcoinsTip->HaveCoins(hash))
tx.AcceptToMemoryPool(false);
}
}
return AcceptToMemoryPool(false);
}
return false;
}
bool CWalletTx::WriteToDisk() bool CWalletTx::WriteToDisk()
{ {
return CWalletDB(pwallet->strWalletFile).WriteTx(GetHash(), *this); return CWalletDB(pwallet->strWalletFile).WriteTx(GetHash(), *this);

Loading…
Cancel
Save