Browse Source

Merge pull request #5105

a96d113 Rename CWalletInterface to CValidationInterface (Pieter Wuille)
0.10
Wladimir J. van der Laan 10 years ago
parent
commit
b88cb1a96e
No known key found for this signature in database
GPG Key ID: 74810B012346C9A6
  1. 4
      src/init.cpp
  2. 30
      src/main.cpp
  3. 28
      src/main.h
  4. 2
      src/test/test_bitcoin.cpp
  5. 2
      src/wallet.h

4
src/init.cpp

@ -170,7 +170,7 @@ void Shutdown()
#ifndef WIN32 #ifndef WIN32
boost::filesystem::remove(GetPidFile()); boost::filesystem::remove(GetPidFile());
#endif #endif
UnregisterAllWallets(); UnregisterAllValidationInterfaces();
#ifdef ENABLE_WALLET #ifdef ENABLE_WALLET
delete pwalletMain; delete pwalletMain;
pwalletMain = NULL; pwalletMain = NULL;
@ -1154,7 +1154,7 @@ bool AppInit2(boost::thread_group& threadGroup)
LogPrintf("%s", strErrors.str()); LogPrintf("%s", strErrors.str());
LogPrintf(" wallet %15dms\n", GetTimeMillis() - nStart); LogPrintf(" wallet %15dms\n", GetTimeMillis() - nStart);
RegisterWallet(pwalletMain); RegisterValidationInterface(pwalletMain);
CBlockIndex *pindexRescan = chainActive.Tip(); CBlockIndex *pindexRescan = chainActive.Tip();
if (GetBoolArg("-rescan", false)) if (GetBoolArg("-rescan", false))

30
src/main.cpp

@ -156,25 +156,25 @@ struct CMainSignals {
} // anon namespace } // anon namespace
void RegisterWallet(CWalletInterface* pwalletIn) { void RegisterValidationInterface(CValidationInterface* pwalletIn) {
g_signals.SyncTransaction.connect(boost::bind(&CWalletInterface::SyncTransaction, pwalletIn, _1, _2)); g_signals.SyncTransaction.connect(boost::bind(&CValidationInterface::SyncTransaction, pwalletIn, _1, _2));
g_signals.EraseTransaction.connect(boost::bind(&CWalletInterface::EraseFromWallet, pwalletIn, _1)); g_signals.EraseTransaction.connect(boost::bind(&CValidationInterface::EraseFromWallet, pwalletIn, _1));
g_signals.UpdatedTransaction.connect(boost::bind(&CWalletInterface::UpdatedTransaction, pwalletIn, _1)); g_signals.UpdatedTransaction.connect(boost::bind(&CValidationInterface::UpdatedTransaction, pwalletIn, _1));
g_signals.SetBestChain.connect(boost::bind(&CWalletInterface::SetBestChain, pwalletIn, _1)); g_signals.SetBestChain.connect(boost::bind(&CValidationInterface::SetBestChain, pwalletIn, _1));
g_signals.Inventory.connect(boost::bind(&CWalletInterface::Inventory, pwalletIn, _1)); g_signals.Inventory.connect(boost::bind(&CValidationInterface::Inventory, pwalletIn, _1));
g_signals.Broadcast.connect(boost::bind(&CWalletInterface::ResendWalletTransactions, pwalletIn)); g_signals.Broadcast.connect(boost::bind(&CValidationInterface::ResendWalletTransactions, pwalletIn));
} }
void UnregisterWallet(CWalletInterface* pwalletIn) { void UnregisterValidationInterface(CValidationInterface* pwalletIn) {
g_signals.Broadcast.disconnect(boost::bind(&CWalletInterface::ResendWalletTransactions, pwalletIn)); g_signals.Broadcast.disconnect(boost::bind(&CValidationInterface::ResendWalletTransactions, pwalletIn));
g_signals.Inventory.disconnect(boost::bind(&CWalletInterface::Inventory, pwalletIn, _1)); g_signals.Inventory.disconnect(boost::bind(&CValidationInterface::Inventory, pwalletIn, _1));
g_signals.SetBestChain.disconnect(boost::bind(&CWalletInterface::SetBestChain, pwalletIn, _1)); g_signals.SetBestChain.disconnect(boost::bind(&CValidationInterface::SetBestChain, pwalletIn, _1));
g_signals.UpdatedTransaction.disconnect(boost::bind(&CWalletInterface::UpdatedTransaction, pwalletIn, _1)); g_signals.UpdatedTransaction.disconnect(boost::bind(&CValidationInterface::UpdatedTransaction, pwalletIn, _1));
g_signals.EraseTransaction.disconnect(boost::bind(&CWalletInterface::EraseFromWallet, pwalletIn, _1)); g_signals.EraseTransaction.disconnect(boost::bind(&CValidationInterface::EraseFromWallet, pwalletIn, _1));
g_signals.SyncTransaction.disconnect(boost::bind(&CWalletInterface::SyncTransaction, pwalletIn, _1, _2)); g_signals.SyncTransaction.disconnect(boost::bind(&CValidationInterface::SyncTransaction, pwalletIn, _1, _2));
} }
void UnregisterAllWallets() { void UnregisterAllValidationInterfaces() {
g_signals.Broadcast.disconnect_all_slots(); g_signals.Broadcast.disconnect_all_slots();
g_signals.Inventory.disconnect_all_slots(); g_signals.Inventory.disconnect_all_slots();
g_signals.SetBestChain.disconnect_all_slots(); g_signals.SetBestChain.disconnect_all_slots();

28
src/main.h

@ -129,17 +129,17 @@ class CBlockTreeDB;
class CTxUndo; class CTxUndo;
class CScriptCheck; class CScriptCheck;
class CValidationState; class CValidationState;
class CWalletInterface; class CValidationInterface;
struct CNodeStateStats; struct CNodeStateStats;
struct CBlockTemplate; struct CBlockTemplate;
/** Register a wallet to receive updates from core */ /** Register a wallet to receive updates from core */
void RegisterWallet(CWalletInterface* pwalletIn); void RegisterValidationInterface(CValidationInterface* pwalletIn);
/** Unregister a wallet from core */ /** Unregister a wallet from core */
void UnregisterWallet(CWalletInterface* pwalletIn); void UnregisterValidationInterface(CValidationInterface* pwalletIn);
/** Unregister all wallets from core */ /** Unregister all wallets from core */
void UnregisterAllWallets(); void UnregisterAllValidationInterfaces();
/** Push an updated transaction to all registered wallets */ /** Push an updated transaction to all registered wallets */
void SyncWithWallets(const CTransaction& tx, const CBlock* pblock = NULL); void SyncWithWallets(const CTransaction& tx, const CBlock* pblock = NULL);
@ -640,17 +640,17 @@ public:
}; };
class CWalletInterface { class CValidationInterface {
protected: protected:
virtual void SyncTransaction(const CTransaction &tx, const CBlock *pblock) =0; virtual void SyncTransaction(const CTransaction &tx, const CBlock *pblock) {};
virtual void EraseFromWallet(const uint256 &hash) =0; virtual void EraseFromWallet(const uint256 &hash) {};
virtual void SetBestChain(const CBlockLocator &locator) =0; virtual void SetBestChain(const CBlockLocator &locator) {};
virtual void UpdatedTransaction(const uint256 &hash) =0; virtual void UpdatedTransaction(const uint256 &hash) {};
virtual void Inventory(const uint256 &hash) =0; virtual void Inventory(const uint256 &hash) {};
virtual void ResendWalletTransactions() =0; virtual void ResendWalletTransactions() {};
friend void ::RegisterWallet(CWalletInterface*); friend void ::RegisterValidationInterface(CValidationInterface*);
friend void ::UnregisterWallet(CWalletInterface*); friend void ::UnregisterValidationInterface(CValidationInterface*);
friend void ::UnregisterAllWallets(); friend void ::UnregisterAllValidationInterfaces();
}; };
#endif // BITCOIN_MAIN_H #endif // BITCOIN_MAIN_H

2
src/test/test_bitcoin.cpp

@ -47,7 +47,7 @@ struct TestingSetup {
bool fFirstRun; bool fFirstRun;
pwalletMain = new CWallet("wallet.dat"); pwalletMain = new CWallet("wallet.dat");
pwalletMain->LoadWallet(fFirstRun); pwalletMain->LoadWallet(fFirstRun);
RegisterWallet(pwalletMain); RegisterValidationInterface(pwalletMain);
#endif #endif
nScriptCheckThreads = 3; nScriptCheckThreads = 3;
for (int i=0; i < nScriptCheckThreads-1; i++) for (int i=0; i < nScriptCheckThreads-1; i++)

2
src/wallet.h

@ -95,7 +95,7 @@ public:
/** A CWallet is an extension of a keystore, which also maintains a set of transactions and balances, /** A CWallet is an extension of a keystore, which also maintains a set of transactions and balances,
* and provides the ability to create new transactions. * and provides the ability to create new transactions.
*/ */
class CWallet : public CCryptoKeyStore, public CWalletInterface class CWallet : public CCryptoKeyStore, public CValidationInterface
{ {
private: private:
bool SelectCoins(const CAmount& nTargetValue, std::set<std::pair<const CWalletTx*,unsigned int> >& setCoinsRet, CAmount& nValueRet, const CCoinControl *coinControl = NULL) const; bool SelectCoins(const CAmount& nTargetValue, std::set<std::pair<const CWalletTx*,unsigned int> >& setCoinsRet, CAmount& nValueRet, const CCoinControl *coinControl = NULL) const;

Loading…
Cancel
Save