HomePhabricator

p2p, refactor: pass and use uint16_t CService::port as uint16_t

Description

p2p, refactor: pass and use uint16_t CService::port as uint16_t

Summary:

As noticed during review of the I2P network support, CService::port is uint16_t but is passed around the codebase and into the ctors as int, which causes uneeded conversions and casts. We can avoid these (including in the incoming I2P code without further changes to it) by using ports with the correct type. The remaining conversions are pushed out to the user input boundaries where they can be range-checked and raise with user feedback in the next patch.

This is a backport of core#21328 [1/3]
https://github.com/bitcoin/bitcoin/pull/21328/commits/6423c8175fad3163c10ffdb49e0df48e4e4931f1

Test Plan: ninja all check-all

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

Differential Revision: https://reviews.bitcoinabc.org/D11077

Details

Provenance
Jon Atack <jon@atack.com>Authored on Mar 1 2021, 20:35
PiRKCommitted on Feb 21 2022, 13:22
PiRKPushed on Feb 21 2022, 13:22
Reviewer
Restricted Project
Differential Revision
D11077: p2p, refactor: pass and use uint16_t CService::port as uint16_t
Parents
rABCa898bfeb1cc6: net, doc: Doxygen updates and fixes in netbase.{h,cpp}
Branches
Unknown
Tags
Unknown