Page MenuHomePhabricator

[net processing] Refactor MaybeSendAddr()
ClosedPublic

Authored by PiRK on Jan 27 2022, 16:17.

Details

Reviewers
Fabien
Group Reviewers
Restricted Project
Commits
rABC6865c990333f: [net processing] Refactor MaybeSendAddr()
Summary

Changes to make MaybeSendAddr simpler and easier to maintain/update:

  • assert invariant that node.vAddrToSend.size() can never exceed MAX_ADDR_TO_SEND
  • erase known addresses from vAddrToSend in one pass
  • no check for (vAddr.size() >= MAX_ADDR_TO_SEND) during iteration, since vAddr can never exceed MAX_ADDR_TO_SEND.

Note: we used GetMaxAddrToSend() instead of MAX_ADDR_TO_SEND because it can be overriden by the -maxaddrtosend command line option (D10823]

This concludes backport of core#21236 [6/6]
https://github.com/bitcoin/bitcoin/pull/21236/commits/935d4889228e7e361c8b0020761fa0e08a55fb48

Depends on D10919

Test Plan

ninja all check-all

Event Timeline

PiRK requested review of this revision.Jan 27 2022, 16:17
Fabien requested changes to this revision.Jan 27 2022, 17:02
Fabien added a subscriber: Fabien.
Fabien added inline comments.
src/net_processing.cpp
5651 ↗(On Diff #32021)

you can store the output of GetMaxAddrToSend() in a local var to avoid calling it twice in a row

This revision now requires changes to proceed.Jan 27 2022, 17:02

store the output of GetMaxAddrToSend in a local var

Tail of the build log:

wallet_abandonconflict.py                 | ✓ Passed  | 13 s
wallet_address_types.py                   | ✓ Passed  | 16 s
wallet_address_types.py --descriptors     | ✓ Passed  | 11 s
wallet_avoidreuse.py                      | ✓ Passed  | 4 s
wallet_avoidreuse.py --descriptors        | ✓ Passed  | 4 s
wallet_backup.py                          | ✓ Passed  | 23 s
wallet_balance.py                         | ✓ Passed  | 7 s
wallet_balance.py --descriptors           | ✓ Passed  | 17 s
wallet_basic.py                           | ✓ Passed  | 24 s
wallet_coinbase_category.py               | ✓ Passed  | 1 s
wallet_create_tx.py                       | ✓ Passed  | 6 s
wallet_createwallet.py                    | ✓ Passed  | 2 s
wallet_createwallet.py --descriptors      | ✓ Passed  | 2 s
wallet_createwallet.py --usecli           | ✓ Passed  | 3 s
wallet_descriptor.py                      | ✓ Passed  | 6 s
wallet_disable.py                         | ✓ Passed  | 0 s
wallet_dump.py                            | ✓ Passed  | 5 s
wallet_encryption.py                      | ✓ Passed  | 5 s
wallet_encryption.py --descriptors        | ✓ Passed  | 5 s
wallet_hd.py                              | ✓ Passed  | 6 s
wallet_hd.py --descriptors                | ✓ Passed  | 5 s
wallet_import_rescan.py                   | ✓ Passed  | 5 s
wallet_import_with_label.py               | ✓ Passed  | 1 s
wallet_importdescriptors.py               | ✓ Passed  | 6 s
wallet_importmulti.py                     | ✓ Passed  | 3 s
wallet_importprunedfunds.py               | ✓ Passed  | 2 s
wallet_importprunedfunds.py --descriptors | ✓ Passed  | 2 s
wallet_keypool.py                         | ✓ Passed  | 3 s
wallet_keypool_topup.py                   | ✓ Passed  | 2 s
wallet_keypool_topup.py --descriptors     | ✓ Passed  | 3 s
wallet_labels.py                          | ✓ Passed  | 2 s
wallet_labels.py --descriptors            | ✓ Passed  | 2 s
wallet_listreceivedby.py                  | ✓ Passed  | 19 s
wallet_listsinceblock.py                  | ✓ Passed  | 4 s
wallet_listsinceblock.py --descriptors    | ✓ Passed  | 9 s
wallet_listtransactions.py                | ✓ Passed  | 4 s
wallet_listtransactions.py --descriptors  | ✓ Passed  | 3 s
wallet_multiwallet.py                     | ✓ Passed  | 38 s
wallet_multiwallet.py --usecli            | ✓ Passed  | 10 s
wallet_reorgsrestore.py                   | ✓ Passed  | 3 s
wallet_resendwallettransactions.py        | ✓ Passed  | 3 s
wallet_send.py                            | ✓ Passed  | 7 s
wallet_startup.py                         | ✓ Passed  | 2 s
wallet_txn_clone.py                       | ✓ Passed  | 2 s
wallet_txn_clone.py --mineblock           | ✓ Passed  | 3 s
wallet_txn_doublespend.py                 | ✓ Passed  | 1 s
wallet_txn_doublespend.py --mineblock     | ✓ Passed  | 3 s
wallet_watchonly.py                       | ✓ Passed  | 1 s
wallet_watchonly.py --usecli              | ✓ Passed  | 1 s

ALL                                       | ✓ Passed  | 1047 s (accumulated) 
Runtime: 210 s

----------------------------------------------------------------------
Ran 10 tests in 0.093s

OK

ninja: build stopped: cannot make progress due to previous errors.
Build build-diff failed with exit code 1

rebase (unrelated CI failure)

Fabien added inline comments.
src/net_processing.cpp
5651

const

This revision is now accepted and ready to land.Jan 28 2022, 09:14