|
5 | 5 |
|
6 | 6 | #include "main.h"
|
7 | 7 |
|
8 |
| -#include "arith_uint256.h" |
9 | 8 | #include "addrman.h"
|
10 | 9 | #include "alert.h"
|
| 10 | +#include "arith_uint256.h" |
11 | 11 | #include "chainparams.h"
|
12 | 12 | #include "checkpoints.h"
|
13 | 13 | #include "checkqueue.h"
|
|
21 | 21 | #include "undo.h"
|
22 | 22 | #include "util.h"
|
23 | 23 | #include "utilmoneystr.h"
|
| 24 | +#include "validationinterface.h" |
24 | 25 |
|
25 | 26 | #include <sstream>
|
26 | 27 |
|
@@ -156,68 +157,6 @@ namespace {
|
156 | 157 | set<int> setDirtyFileInfo;
|
157 | 158 | } // anon namespace
|
158 | 159 |
|
159 |
| -////////////////////////////////////////////////////////////////////////////// |
160 |
| -// |
161 |
| -// dispatching functions |
162 |
| -// |
163 |
| - |
164 |
| -// These functions dispatch to one or all registered wallets |
165 |
| - |
166 |
| -namespace { |
167 |
| - |
168 |
| -struct CMainSignals { |
169 |
| - /** Notifies listeners of updated transaction data (transaction, and optionally the block it is found in. */ |
170 |
| - boost::signals2::signal<void (const CTransaction &, const CBlock *)> SyncTransaction; |
171 |
| - /** Notifies listeners of an erased transaction (currently disabled, requires transaction replacement). */ |
172 |
| - boost::signals2::signal<void (const uint256 &)> EraseTransaction; |
173 |
| - /** Notifies listeners of an updated transaction without new data (for now: a coinbase potentially becoming visible). */ |
174 |
| - boost::signals2::signal<void (const uint256 &)> UpdatedTransaction; |
175 |
| - /** Notifies listeners of a new active block chain. */ |
176 |
| - boost::signals2::signal<void (const CBlockLocator &)> SetBestChain; |
177 |
| - /** Notifies listeners about an inventory item being seen on the network. */ |
178 |
| - boost::signals2::signal<void (const uint256 &)> Inventory; |
179 |
| - /** Tells listeners to broadcast their data. */ |
180 |
| - boost::signals2::signal<void ()> Broadcast; |
181 |
| - /** Notifies listeners of a block validation result */ |
182 |
| - boost::signals2::signal<void (const CBlock&, const CValidationState&)> BlockChecked; |
183 |
| -} g_signals; |
184 |
| - |
185 |
| -} // anon namespace |
186 |
| - |
187 |
| -void RegisterValidationInterface(CValidationInterface* pwalletIn) { |
188 |
| - g_signals.SyncTransaction.connect(boost::bind(&CValidationInterface::SyncTransaction, pwalletIn, _1, _2)); |
189 |
| - g_signals.EraseTransaction.connect(boost::bind(&CValidationInterface::EraseFromWallet, pwalletIn, _1)); |
190 |
| - g_signals.UpdatedTransaction.connect(boost::bind(&CValidationInterface::UpdatedTransaction, pwalletIn, _1)); |
191 |
| - g_signals.SetBestChain.connect(boost::bind(&CValidationInterface::SetBestChain, pwalletIn, _1)); |
192 |
| - g_signals.Inventory.connect(boost::bind(&CValidationInterface::Inventory, pwalletIn, _1)); |
193 |
| - g_signals.Broadcast.connect(boost::bind(&CValidationInterface::ResendWalletTransactions, pwalletIn)); |
194 |
| - g_signals.BlockChecked.connect(boost::bind(&CValidationInterface::BlockChecked, pwalletIn, _1, _2)); |
195 |
| -} |
196 |
| - |
197 |
| -void UnregisterValidationInterface(CValidationInterface* pwalletIn) { |
198 |
| - g_signals.BlockChecked.disconnect(boost::bind(&CValidationInterface::BlockChecked, pwalletIn, _1, _2)); |
199 |
| - g_signals.Broadcast.disconnect(boost::bind(&CValidationInterface::ResendWalletTransactions, pwalletIn)); |
200 |
| - g_signals.Inventory.disconnect(boost::bind(&CValidationInterface::Inventory, pwalletIn, _1)); |
201 |
| - g_signals.SetBestChain.disconnect(boost::bind(&CValidationInterface::SetBestChain, pwalletIn, _1)); |
202 |
| - g_signals.UpdatedTransaction.disconnect(boost::bind(&CValidationInterface::UpdatedTransaction, pwalletIn, _1)); |
203 |
| - g_signals.EraseTransaction.disconnect(boost::bind(&CValidationInterface::EraseFromWallet, pwalletIn, _1)); |
204 |
| - g_signals.SyncTransaction.disconnect(boost::bind(&CValidationInterface::SyncTransaction, pwalletIn, _1, _2)); |
205 |
| -} |
206 |
| - |
207 |
| -void UnregisterAllValidationInterfaces() { |
208 |
| - g_signals.BlockChecked.disconnect_all_slots(); |
209 |
| - g_signals.Broadcast.disconnect_all_slots(); |
210 |
| - g_signals.Inventory.disconnect_all_slots(); |
211 |
| - g_signals.SetBestChain.disconnect_all_slots(); |
212 |
| - g_signals.UpdatedTransaction.disconnect_all_slots(); |
213 |
| - g_signals.EraseTransaction.disconnect_all_slots(); |
214 |
| - g_signals.SyncTransaction.disconnect_all_slots(); |
215 |
| -} |
216 |
| - |
217 |
| -void SyncWithWallets(const CTransaction &tx, const CBlock *pblock) { |
218 |
| - g_signals.SyncTransaction(tx, pblock); |
219 |
| -} |
220 |
| - |
221 | 160 | //////////////////////////////////////////////////////////////////////////////
|
222 | 161 | //
|
223 | 162 | // Registration of network node signals.
|
@@ -1897,7 +1836,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
|
1897 | 1836 |
|
1898 | 1837 | // Watch for changes to the previous coinbase transaction.
|
1899 | 1838 | static uint256 hashPrevBestCoinBase;
|
1900 |
| - g_signals.UpdatedTransaction(hashPrevBestCoinBase); |
| 1839 | + GetMainSignals().UpdatedTransaction(hashPrevBestCoinBase); |
1901 | 1840 | hashPrevBestCoinBase = block.vtx[0].GetHash();
|
1902 | 1841 |
|
1903 | 1842 | int64_t nTime4 = GetTimeMicros(); nTimeCallbacks += nTime4 - nTime3;
|
@@ -1956,7 +1895,7 @@ bool static FlushStateToDisk(CValidationState &state, FlushStateMode mode) {
|
1956 | 1895 | return state.Abort("Failed to write to coin database");
|
1957 | 1896 | // Update best block in wallet (so we can detect restored wallets).
|
1958 | 1897 | if (mode != FLUSH_STATE_IF_NEEDED) {
|
1959 |
| - g_signals.SetBestChain(chainActive.GetLocator()); |
| 1898 | + GetMainSignals().SetBestChain(chainActive.GetLocator()); |
1960 | 1899 | }
|
1961 | 1900 | nLastWrite = GetTimeMicros();
|
1962 | 1901 | }
|
@@ -2080,7 +2019,7 @@ bool static ConnectTip(CValidationState &state, CBlockIndex *pindexNew, CBlock *
|
2080 | 2019 | CCoinsViewCache view(pcoinsTip);
|
2081 | 2020 | CInv inv(MSG_BLOCK, pindexNew->GetBlockHash());
|
2082 | 2021 | bool rv = ConnectBlock(*pblock, state, pindexNew, view);
|
2083 |
| - g_signals.BlockChecked(*pblock, state); |
| 2022 | + GetMainSignals().BlockChecked(*pblock, state); |
2084 | 2023 | if (!rv) {
|
2085 | 2024 | if (state.IsInvalid())
|
2086 | 2025 | InvalidBlockFound(pindexNew, state);
|
@@ -3471,7 +3410,7 @@ void static ProcessGetData(CNode* pfrom)
|
3471 | 3410 | }
|
3472 | 3411 |
|
3473 | 3412 | // Track requests for our stuff.
|
3474 |
| - g_signals.Inventory(inv.hash); |
| 3413 | + GetMainSignals().Inventory(inv.hash); |
3475 | 3414 |
|
3476 | 3415 | if (inv.type == MSG_BLOCK || inv.type == MSG_FILTERED_BLOCK)
|
3477 | 3416 | break;
|
@@ -3765,7 +3704,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
|
3765 | 3704 | }
|
3766 | 3705 |
|
3767 | 3706 | // Track requests for our stuff
|
3768 |
| - g_signals.Inventory(inv.hash); |
| 3707 | + GetMainSignals().Inventory(inv.hash); |
3769 | 3708 |
|
3770 | 3709 | if (pfrom->nSendSize > (SendBufferSize() * 2)) {
|
3771 | 3710 | Misbehaving(pfrom->GetId(), 50);
|
@@ -4536,7 +4475,7 @@ bool SendMessages(CNode* pto, bool fSendTrickle)
|
4536 | 4475 | // transactions become unconfirmed and spams other nodes.
|
4537 | 4476 | if (!fReindex && !fImporting && !IsInitialBlockDownload())
|
4538 | 4477 | {
|
4539 |
| - g_signals.Broadcast(); |
| 4478 | + GetMainSignals().Broadcast(); |
4540 | 4479 | }
|
4541 | 4480 |
|
4542 | 4481 | //
|
|
0 commit comments