HomePhabricator

[avalanche] Remove unnecessary peer lookup after modifying the peer set

Description

[avalanche] Remove unnecessary peer lookup after modifying the peer set

Summary:
The PeerManager::removeNodeFromPeer() methods calls modify() on the
peer set, and an additional lookup is performed to make sure the
iterator did not get invalidated during the operation. However according
to the documentation:

Validity of position is preserved if the operation succeeds

where position is the iterator:
https://www.boost.org/doc/libs/1_51_0/libs/multi_index/doc/reference/hash_indices.html#modify

Since the return value of the modify call is checked, the iterator is
guaranteed to remain valid. Furthermore, no key is modified which gives
an additional guarantee.

Test Plan:

ninja all check-all

Reviewers: #bitcoin_abc, deadalnix

Reviewed By: #bitcoin_abc, deadalnix

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

Details

Provenance
FabienAuthored on Jun 24 2021, 12:10
FabienPushed on Jun 24 2021, 19:20
Reviewer
Restricted Project
Differential Revision
D9699: [avalanche] Remove unnecessary peer lookup after modifying the peer set
Parents
rABC08cc13190586: [avalanche] Generate a single block in tests
Branches
Unknown
Tags
Unknown