HomePhabricator

refactor: replace CNode pointers by references within net_processing.{h,cpp}

Description

refactor: replace CNode pointers by references within net_processing.{h,cpp}

Summary:

This PR is inspired by a recent code review comment on a PR that
introduced new functions to the net_processing module. The point of the
discussion was basically that whenever we pass something not by value
(in the concrete example it was about CNode* and CConnman*) we should
either use

    a pointer (CType*) with null pointer check or
    a reference (CType&)

To keep things simple, this PR for a first approach

    only tackles CNode* pointers
    only within the net_processing module, i.e. no changes that would
need adaption in other modules
    keeps the names of the variables as they are

I'm aware that PRs like this are kind of a PITA to review, but I think
the code quality would increase if we get rid of pointers without
nullptr check -- bloating up the code by adding all the missing checks
would be the worse alternative, in my opinion.

Possible follow-up PRs, in case this is received well:

    replace CNode pointers by references for net module
    replace CConnman pointers by references for net_processing module
    ...

Backport of core PR19053.

Depends on D8469.

Test Plan:

ninja all check-all

Reviewers: #bitcoin_abc, jasonbcox

Reviewed By: #bitcoin_abc, jasonbcox

Subscribers: jasonbcox

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

Details

Provenance
Sebastian Falbesoner <sebastian.falbesoner@gmail.com>Authored on May 22 2020, 15:52
FabienCommitted on Nov 19 2020, 18:38
FabienPushed on Nov 19 2020, 18:39
Reviewer
Restricted Project
Differential Revision
D8470: refactor: replace CNode pointers by references within net_processing.{h,cpp}
Parents
rABCeb6fae51773f: net processing: Add support for getcfilters
Branches
Unknown
Tags
Unknown