From 4506fd30cb3f00a89e818ce29345e089aae45cea Mon Sep 17 00:00:00 2001 From: yyforyongyu Date: Tue, 12 Nov 2024 23:55:13 +0800 Subject: [PATCH] lntest: change the `nodeCounter` to be atomic --- lntest/harness_node_manager.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lntest/harness_node_manager.go b/lntest/harness_node_manager.go index 90a74f75e..6ad4b9031 100644 --- a/lntest/harness_node_manager.go +++ b/lntest/harness_node_manager.go @@ -46,7 +46,7 @@ type nodeManager struct { // nodeCounter is a monotonically increasing counter that's used as the // node's unique ID. - nodeCounter uint32 + nodeCounter atomic.Uint32 // feeServiceURL is the url of the fee service. feeServiceURL string @@ -67,8 +67,8 @@ func newNodeManager(lndBinary string, dbBackend node.DatabaseBackend, // nextNodeID generates a unique sequence to be used as the node's ID. func (nm *nodeManager) nextNodeID() uint32 { - nodeID := atomic.AddUint32(&nm.nodeCounter, 1) - return nodeID - 1 + nodeID := nm.nodeCounter.Add(1) + return nodeID } // newNode initializes a new HarnessNode, supporting the ability to initialize