Commit graph

42 commits

Author SHA1 Message Date
Matt Corallo 97d2b09c12 Add helper to wait for validation interface queue to catch up 2017-12-26 11:56:00 -05:00
Matt Corallo 5a933cefcc Add an interface to get the queue depth out of CValidationInterface 2017-12-26 11:54:49 -05:00
MeshCollider 1a445343f6 scripted-diff: Replace #include "" with #include <> (ryanofsky)
-BEGIN VERIFY SCRIPT-
for f in \
  src/*.cpp \
  src/*.h \
  src/bench/*.cpp \
  src/bench/*.h \
  src/compat/*.cpp \
  src/compat/*.h \
  src/consensus/*.cpp \
  src/consensus/*.h \
  src/crypto/*.cpp \
  src/crypto/*.h \
  src/crypto/ctaes/*.h \
  src/policy/*.cpp \
  src/policy/*.h \
  src/primitives/*.cpp \
  src/primitives/*.h \
  src/qt/*.cpp \
  src/qt/*.h \
  src/qt/test/*.cpp \
  src/qt/test/*.h \
  src/rpc/*.cpp \
  src/rpc/*.h \
  src/script/*.cpp \
  src/script/*.h \
  src/support/*.cpp \
  src/support/*.h \
  src/support/allocators/*.h \
  src/test/*.cpp \
  src/test/*.h \
  src/wallet/*.cpp \
  src/wallet/*.h \
  src/wallet/test/*.cpp \
  src/wallet/test/*.h \
  src/zmq/*.cpp \
  src/zmq/*.h
do
  base=${f%/*}/ relbase=${base#src/} sed -i "s:#include \"\(.*\)\"\(.*\):if test -e \$base'\\1'; then echo \"#include <\"\$relbase\"\\1>\\2\"; else echo \"#include <\\1>\\2\"; fi:e" $f
done
-END VERIFY SCRIPT-
2017-11-16 08:23:01 +13:00
Matt Corallo 3ea8b75281 Give ZMQ consistent order with UpdatedBlockTip on scheduler thread
Note that UpdatedBlockTip is also used in net_processing to
announce new blocks to peers. As this may need additional review,
this change is included in its own commit.
2017-10-13 19:30:15 -04:00
Matt Corallo e545dedf72 Also call other wallet notify callbacks in scheduler thread
This runs Block{Connected,Disconnected}, SetBestChain, Inventory,
and TransactionAddedToMempool on the background scheduler thread.

Of those, only BlockConnected is used outside of Wallet/ZMQ, and
is used only for orphan transaction removal in net_processing,
something which does not need to be synchronous with anything
else.

This partially reverts #9583, re-enabling some of the gains from
 #7946. This does not, however, re-enable the gains achieved by
repeatedly releasing cs_main between each transaction processed.
2017-10-13 19:30:15 -04:00
Matt Corallo 0b2f42d737 Add CallFunctionInQueue to wait on validation interface queue drain 2017-10-13 19:29:54 -04:00
Matt Corallo 0343676ce3 Call TransactionRemovedFromMempool in the CScheduler thread
This is both good practice (we want to move all such callbacks
into a background thread eventually) and prevents a lock inversion
when we go to use this in wallet (mempool.cs->cs_wallet and
cs_wallet->mempool.cs would otherwise both be used).
2017-10-13 19:29:54 -04:00
Matt Corallo a7d3936de8 Add a CValidationInterface::TransactionRemovedFromMempool
This is currently unused, but will by used by wallet to cache when
transactions are in the mempool, obviating the need for calls to
mempool from CWalletTx::InMempool()
2017-10-13 19:29:54 -04:00
practicalswift e061d8d7ab Remove declaration of unused function: void UpdatedTransaction(const uint256 &) 2017-07-15 20:04:04 +02:00
Matt Corallo 3192975f1d Flush CValidationInterface callbacks prior to destruction
Note that the CScheduler thread cant be running at this point,
it has already been stopped with the rest of the init threadgroup.
Thus, just calling any remaining loose callbacks during Shutdown()
is sane.
2017-07-07 12:55:57 -04:00
Matt Corallo 08096bbbc6 Support more than one CScheduler thread for serial clients
This will be used by CValidationInterface soon.

This requires a bit of work as we need to ensure that most of our
callbacks happen in-order (to avoid synchronization issues in
wallet) - we keep our own internal queue and push things onto it,
scheduling a queue-draining function immediately upon new
callbacks.
2017-07-07 11:33:18 -04:00
Matt Corallo cda1429d5b Give CMainSignals a reference to the global scheduler
...so that it can run some signals in the background later
2017-07-07 11:33:18 -04:00
Matt Corallo 3a19fed9db Make ValidationInterface signals-type-agnostic
(by hiding boost::signals stuff in the .cpp)

This allows us to give it a bit more intelligence as we move
forward, including routing some signals through CScheduler. While
the introduction of a "internals" pointer in the class is pretty
ugly, the fact that we no longer need to include boost/signals
directly from validationinterface.h is very much worth the loss.
2017-07-03 20:54:36 -04:00
Wladimir J. van der Laan df7e2f057b rpc: Move the generate RPC call to rpcwallet
This makes it possible to mine to any wallet when multi-wallet mode is added.
Solves the same problem as #10649, but IMO in a cleaner way.

It also gets rid of the circuitous `ScriptForMining` method on
`CValidationInterface`, which really doesn't belong there.

After this change it's still possible to mine without wallet through
`generatetoaddress`.
2017-06-29 12:02:43 +02:00
Matt Corallo 9fececb2cb Remove CValidationInterface::UpdatedTransaction
This removes another callback from block connection logic, making it
easier to reason about the wallet-RPCs-returns-stale-info issue.

UpdatedTransaction was previously used by the GUI to display
coinbase transactions only after they have a block built on top of
them. This worked fine for in most cases, but only worked due to a
corner case if the user received a coinbase payout in a block
immediately prior to restart. In that case, the normal process of
caching the most recent coinbase transaction's hash would not work,
and instead it would only work because of the on-load -checkblocks
calling DisconnectBlock and ConnectBlock on the current tip.

In order to make this more robust, a full mapWallet loop after the
first block which is connected after restart was added.
2017-04-13 10:36:21 -04:00
Matt Corallo 1c95e2f9c9 Use std::shared_ptr instead of boost::shared_ptr in ScriptForMining 2017-04-07 11:53:43 +02:00
Matt Corallo 91f1e6ce5e Remove dead-code tracking of requests for blocks we generated 2017-04-07 11:53:43 +02:00
Matt Corallo 461e49fee2 SyncTransaction->TxAddedToMempool/BlockConnected/Disconnected
This simplifies fixing the wallet-returns-stale-info issue as we
can now hold cs_wallet across an entire block instead of only
per-tx (though we only actually do so in the next commit).

This change also removes the NOT_IN_BLOCK constant in favor of only
passing the CBlockIndex* parameter to SyncTransactions when a new
block is being connected, instead of also when a block is being
disconnected.

This change adds a parameter to BlockConnectedDisconnected which
lists the transactions which were removed from mempool due to
confliction as a result of this operation. While its somewhat of a
shame to make block-validation-logic generate a list of mempool
changes to be included in its generated callbacks, fixing this isnt
too hard.

Further in this change-set, CValidationInterface starts listening
to mempool directly, placing it in the middle and giving it a bit
of logic to know how to route notifications from block-validation,
mempool, etc (though not listening for conflicted-removals yet).
2017-04-07 11:53:43 +02:00
Jonas Schnelli 7b585cf70e
Merge #9558: Clarify assumptions made about when BlockCheck is called
c4a6929 Clarify assumptions made about when BlockCheck is called (Matt Corallo)

Tree-SHA512: 2eceb0c4f06c7fd6b290b93843bda11a4b63131559c5e8226bfec84596ed4e54ee6d8f5bc9cf789a80675be8b8079cf9234c96032df306258cb2260b9d8c7825
2017-03-23 08:18:43 +01:00
practicalswift 0c9b9b7d64 [trivial] Fix recently introduced typos in comments 2017-02-14 20:19:40 +01:00
Alex Morcos 094e4b3383 Better document usage of SyncTransaction 2017-01-23 15:43:22 -05:00
Matt Corallo c4a6929a3d Clarify assumptions made about when BlockCheck is called 2017-01-14 13:40:46 -08:00
Matt Corallo 6987219577 Add a CValidationInterface::NewPoWValidBlock callback 2017-01-05 10:32:07 -05:00
isle2983 27765b6403 Increment MIT Licence copyright header year on files modified in 2016
Edited via:

$ contrib/devtools/copyright_header.py update .
2016-12-31 11:01:21 -07:00
Matt Corallo 7565e03b96 Remove SyncWithWallets wrapper function 2016-10-04 13:53:04 -04:00
Matt Corallo 87e7d72807 Make validationinterface.UpdatedBlockTip more verbose
In anticipation of making all the callbacks out of block processing
flow through it. Note that vHashes will always have something in it
since pindexFork != pindexNewTip.
2016-10-04 12:35:07 -04:00
Cory Fields 5b446dd5b1 net: Pass CConnection to wallet rather than using the global 2016-09-08 12:04:35 -04:00
Jonas Schnelli b3b3c2a562
Reduce cs_main locks during ConnectTip/SyncWithWallets 2016-08-12 14:53:10 +02:00
Wladimir J. van der Laan d2228384de
Merge #6480: include the chaintip blockindex in the SyncTransaction signal, add signal UpdateTip()
7d0bf0b include the chaintip *blockIndex in the SyncTransaction signal (Jonas Schnelli)
2016-02-04 17:03:09 +01:00
MarcoFalke fa24439ff3 Bump copyright headers to 2015 2015-12-13 18:08:39 +01:00
Jonas Schnelli 7d0bf0bb46
include the chaintip *blockIndex in the SyncTransaction signal
- allows reducing of calls to main.cpp for getting the chaintip during transaction syncing
- potentially allows reducing of cs_main locks
2015-12-04 09:18:53 +01:00
Jonas Schnelli d76a8acb9b use CBlockIndex* insted of uint256 for UpdatedBlockTip signal
- removes mapBlockIndex find operation
- theoretically allows removing the cs_main lock during zqm notification while introducing a new file position lock
2015-09-16 16:51:21 +02:00
João Barbosa 5624e055b3 Add UpdatedBlockTip signal to CMainSignals and CValidationInterface 2015-09-16 10:59:32 +01:00
Jonas Schnelli a7b9623d18 miner: rename UpdateRequestCount signal to ResetRequestCount 2015-07-01 16:09:58 +02:00
Jonas Schnelli 5496253966 add CReserveScript to allow modular script keeping/returning
- use one CReserveScript per mining thread
2015-07-01 16:06:14 +02:00
Jonas Schnelli d0fc10a844 detach wallet from miner 2015-06-30 21:45:46 +02:00
Michael Ford 08d9373e2f Remove unused code from wallet and validation interface
Fixes #6109
2015-05-18 17:11:06 +08:00
Philip Kaufmann 0a7bcb7e55 fix IDE/compiler warning "extra ';'" in validationinterface.h 2015-05-14 01:02:00 -04:00
Wladimir J. van der Laan 446bb70fcd
Merge pull request #5940
0f5954c Regression test for ResendWalletTransactions (Gavin Andresen)
2015-03-30 14:28:09 +02:00
Michael Ford 63e4c9cd35 Fix clang compile warnings intriduced in #5681 2015-03-29 19:45:05 +08:00
Gavin Andresen 0f5954c434
Regression test for ResendWalletTransactions
Adds a regression test for the wallet's ResendWalletTransactions function, which uses a new, hidden RPC command "resendwallettransactions."

I refactored main's Broadcast signal so it is passed the best-block time, which let me remove a global variable shared between main.cpp and the wallet (nTimeBestReceived).

I also manually tested the "rebroadcast unconfirmed every half hour or so" functionality by:

1. Running bitcoind -connect=0.0.0.0:8333
2. Creating a couple of send-to-self transactions
3. Connect to a peer using -addnode
4. Waited a while, monitoring debug.log, until I see:
```2015-03-23 18:48:10 ResendWalletTransactions: rebroadcast 2 unconfirmed transactions```

One last change: don't bother putting ResendWalletTransactions messages in debug.log unless unconfirmed transactions were actually rebroadcast.
2015-03-24 15:29:20 -04:00
Jorge Timón 26c16d9de9 Includes: Refactor: Move CValidationInterface and CMainSignals out of main 2015-03-24 17:21:41 +01:00