Skip to content

Conversation

sipa
Copy link
Member

@sipa sipa commented Oct 19, 2013

This pull request converts the custom callback handling (from main to wallet) to using boost::signals2, which allow concurrent modification/execution, and are thread-safe. To implement callbacks, a new CWalletInterface is defined in main, and implemented by wallet. As a result, together with a few more changes, we can break the dependency from init (and indirectly, from main) on wallet.

Two functional cleanups were included as well, namely removing the behaviour where transactions "fFromMe" were always trickled (we shouldn't treat our own transactions differently, privacy leak) and removing the (apparently since-long broken) PrintWallets functionality.

Closes #2965.

@gavinandresen
Copy link
Contributor

ACK concept, and code looks good to me.

Needs at least a sketch of a test plan that exercises all of the signals.

{
if (!fFileBacked)
return false;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By declaring the signals as void, we do lose error reporting from the wallets. Not sure this is a big loss, but in case we'd like to keep this, boost::signals2 has various ways of combining the results from the handlers.

@laanwj
Copy link
Member

laanwj commented Oct 20, 2013

Haven't tested yet, but code lookg good and I like the approach.

@sipa
Copy link
Member Author

sipa commented Oct 20, 2013

@laanwj The reasoning is that there are callbacks from the node/validation to the wallet; they're really just notifications in general, as the node code shouldn't care about what the wallet does with it (in fact, the signal names shouldn't contain "wallet" even, though I chose not to change them here). As EraseFromWallet was only called as a callback, I just simplified the method here. In the case of AddToWalletIfInvolvingMe (which is called internally inside the wallet as well, with a relevant return code), I added a wrapper to use as signal handler.

@laanwj
Copy link
Member

laanwj commented Oct 20, 2013

Ok, thanks, that makes it clear, I was just not sure if it was overlooked or on purpose.

I like the idea of renaming the signals to be more general (so that theoretically non-wallets could also use the API to keep track)

SyncWithWallets -> SyncTransactions
EraseFromWallets -> EraseTransaction
SetBestChain -> stays the same
UpdatedTransaction -> stays the same
Inventory -> stays the same
ResendWalletTransactions -> ResendTransactions

@sipa
Copy link
Member Author

sipa commented Oct 20, 2013

@laanwj Modified the signal names a bit, and added comments.

sipa added 4 commits October 26, 2013 14:49
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.
@sipa
Copy link
Member Author

sipa commented Oct 26, 2013

Rebased.

@BitcoinPullTester
Copy link

Automatic sanity-testing: PASSED, see http://jenkins.bluematt.me/pull-tester/722fa283d04dfe9c70418e69535a08eea06b4377 for binaries and test log.
This test script verifies pulls every time they are updated. It, however, dies sometimes and fails to test properly. If you are waiting on a test, please check timestamps to verify that the test.log is moving at http://jenkins.bluematt.me/pull-tester/current/
Contact BlueMatt on freenode if something looks broken.

@sipa
Copy link
Member Author

sipa commented Oct 26, 2013

@gavinandresen Test plan:

  • Create a transaction in the GUI, and check whether the number of peers that have seen it goes up. This exercises the Inventory signal.
    • Leave the client open until it confirms. This exercises the SyncTransaction signal.
  • Every at most 30 minutes, ResendWalletTransactions should be called (LogPrintf'ed). This exercises the Broadcast signal.
  • Mine a block yourself, and wait until another on top is mined, while leaving the GUI open. The block's payout should appear only when the second block is mined. This exercises the UpdatedTransaction signal.
  • After being fully synchronized, wait for a block whose height is a multiple of 144, and forcibly kill the client. At startup, the automatic rescan shouldn't go back beyond that 144-multiple block. This exercises the SetBestChain signal.
    • Alternatively, do a -reindex, and wait until a block whose height is a multiple of 20160 is crossed, and do the same kill/restart cycle.

@gavinandresen
Copy link
Contributor

ACK. Ran through test plan with a Bitcoin-Qt in regtest mode and two -regtest bitcoind's, all tests passed.

gavinandresen added a commit that referenced this pull request Oct 30, 2013
Interaction cleanups between main and wallet
@gavinandresen gavinandresen merged commit e13934c into bitcoin:master Oct 30, 2013
Bushstar pushed a commit to Bushstar/omnicore that referenced this pull request Apr 8, 2020
* Add Alpine packages to UNIX build doc

* Add Alpine packages required for building GUI
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Likely Deadlock cs_setpwalletRegistered
4 participants