Improve ScanForWalletTransactions return value #12275

pull ryanofsky wants to merge 1 commits into bitcoin:master from ryanofsky:pr/scanstat changing 4 files +49 −21
  1. ryanofsky commented at 3:05 pm on January 26, 2018: member

    Return more information about scan status from ScanForWalletTransactions and try to describe the return value more clearly.

    There is a slight change in behavior here where rescans that end early due to a reorg will no longer trigger errors. (I incorrectly suggested that that they should trigger errors in the PR where this behavior was introduced: #11281 (review))

  2. ryanofsky commented at 3:15 pm on January 26, 2018: member
    I was originally going to follow up on this change by making RescanFromTime rescan any missed blocks if a scan stopped early because of a reorg (8add443be1c4b82f75d0eca4763fc928b8dbcf08), but I don’t think this should be needed because notifications from the reorg should scan all the relevant blocks.
  3. promag commented at 3:19 pm on January 26, 2018: member
  4. promag commented at 3:21 pm on January 26, 2018: member

    Concept ACK.

    Update comment?: https://github.com/bitcoin/bitcoin/blob/2ae7cf8ef5be67e085abc1b1dc71bc44865a71b3/src/wallet/rpcwallet.cpp#L3511

    Edit: have you considered keeping the return value but adding a CWallet::ScanResult* scan_result = nullptr parameter?

  5. jonasschnelli commented at 6:12 pm on January 26, 2018: contributor
    Thanks for the follow up. Concept ACK. Do we need this for 0.16?
  6. ryanofsky commented at 6:25 pm on January 26, 2018: member

    Do we need this for 0.16?

    I don’t think it should block 0.16, but technically there is a minor regression in 0.16 which this fixes.

    Since #11281, if you call importmulti with rescan=True during a re-org and are very unlucky, there is a chance you could see “Rescan failed for key…” errors returned without this fix. The errors are spurious and do not indicate a real problem. It’d also be possible the fix the problem with a one line-fix, just dropping this line:

    https://github.com/bitcoin/bitcoin/blob/2ae7cf8ef5be67e085abc1b1dc71bc44865a71b3/src/wallet/wallet.cpp#L1698

  7. fanquake added the label Wallet on Jan 26, 2018
  8. in src/wallet/wallet.cpp:1689 in d3b58f0cfb outdated
    1632         }
    1633     }
    1634     return startTime;
    1635 }
    1636 
    1637+void UpdateResult(CWallet::ScanResult& result, const CBlockIndex& block, bool failed)
    


    laanwj commented at 8:13 am on April 5, 2018:
    can be static
  9. laanwj commented at 8:18 am on April 5, 2018: member

    Return more information about scan status from ScanForWalletTransactions and try to describe the return value more clearly.

    Where is this extra return information (intended to) be used?

    Edit: have you considered keeping the return value but adding a CWallet::ScanResult* scan_result = nullptr parameter?

    I prefer returning a tuple or structure to that kind of quasi out-args.

  10. Improve ScanForWalletTransactions return value
    Return more information about scan status from ScanForWalletTransactions and
    try to describe the return value more clearly.
    
    There is a slight change in behavior here where rescans that end early due to a
    reorg will no longer trigger errors. (I incorrectly suggested that that they
    should trigger errors in the PR where this behavior was introduced:
    https://github.com/bitcoin/bitcoin/pull/11281#discussion_r163070403)
    77a03151b5
  11. ryanofsky force-pushed on Apr 11, 2018
  12. Empact commented at 11:52 pm on April 25, 2018: member

    Just want to call out the PR I just opened, #13076, which conflicts with this in that it returns true or false for success or failure (inspired by #11450). An alternative is to return an object like this PR, in which case I would include a few more fields:

    • completed
    • aborted
  13. Empact commented at 11:55 pm on April 25, 2018: member
    In either case, I would bias toward only returning values that are used by the callers and add other fields as needed, in the spirit of YAGNI.
  14. ryanofsky commented at 0:13 am on April 26, 2018: member
    Ok, will close. Regarding YAGNI, I was using the returned status to implement a retry loop in scanfortime which would handle reorgs, but I dropped that commit because I figured incomplete rescans were probably harmless with regular block notifications enabled.
  15. ryanofsky closed this on Apr 26, 2018

  16. meshcollider referenced this in commit ed2a2cebd3 on Dec 12, 2018
  17. Munkybooty referenced this in commit 7d1676d3c3 on Aug 5, 2021
  18. MarcoFalke locked this on Sep 8, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-10-04 22:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me