HomePhabricator

net: dedup and RAII-fy the creation of a copy of CConnman::vNodes

Description

net: dedup and RAII-fy the creation of a copy of CConnman::vNodes

Summary:
The following pattern was duplicated in CConnman:

cpp
lock
create a copy of vNodes, add a reference to each one
unlock
... use the copy ...
lock
release each node from the copy
unlock

Put that code in a RAII helper that reduces it to:

cpp
create snapshot "snap"
... use the copy ...
// release happens when "snap" goes out of scope

This is a partial backport of core#21943
https://github.com/bitcoin/bitcoin/pull/21943/commits/75e8bf55f5a014faada7712a9640dc35e8c86f15

Test Plan: ninja all check-all

Reviewers: #bitcoin_abc, roqqit

Reviewed By: roqqit

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

Details

Provenance
Vasil Dimov <vd@FreeBSD.org>Authored on Apr 26 2021, 14:22
PiRKCommitted on Nov 13 2024, 17:33
PiRKPushed on Nov 13 2024, 17:33
Reviewer
roqqit
Differential Revision
D17106: net: dedup and RAII-fy the creation of a copy of CConnman::vNodes
Parents
rABCe326a15fb768: [Cashtab] Convert agora screen to typescript
Branches
Unknown
Tags
Unknown