@@ -116,8 +116,8 @@ type Builder struct {
116116 started atomic.Bool
117117 stopped atomic.Bool
118118
119- ntfnClientCounter uint64 // To be used atomically.
120- bestHeight uint32 // To be used atomically.
119+ ntfnClientCounter atomic. Uint64
120+ bestHeight atomic. Uint32
121121
122122 cfg * Config
123123
@@ -278,7 +278,7 @@ func (b *Builder) Start() error {
278278 if err != nil {
279279 return err
280280 }
281- b .bestHeight = uint32 (bestHeight )
281+ b .bestHeight . Store ( uint32 (bestHeight ) )
282282
283283 // Before we begin normal operation of the router, we first need
284284 // to synchronize the channel graph to the latest state of the
@@ -340,7 +340,7 @@ func (b *Builder) syncGraphWithChain() error {
340340 if err != nil {
341341 return err
342342 }
343- b .bestHeight = uint32 (bestHeight )
343+ b .bestHeight . Store ( uint32 (bestHeight ) )
344344
345345 pruneHash , pruneHeight , err := b .cfg .Graph .PruneTip ()
346346 if err != nil {
@@ -806,7 +806,7 @@ func (b *Builder) networkHandler() {
806806 // Since this block is stale, we update our best height
807807 // to the previous block.
808808 blockHeight := chainUpdate .Height
809- atomic . StoreUint32 ( & b .bestHeight , blockHeight - 1 )
809+ b .bestHeight . Store ( blockHeight - 1 )
810810
811811 // Update the channel graph to reflect that this block
812812 // was disconnected.
@@ -834,7 +834,7 @@ func (b *Builder) networkHandler() {
834834 // directly to the end of our main chain. If not, then
835835 // we've somehow missed some blocks. Here we'll catch
836836 // up the chain with the latest blocks.
837- currentHeight := atomic . LoadUint32 ( & b .bestHeight )
837+ currentHeight := b .bestHeight . Load ( )
838838 switch {
839839 case chainUpdate .Height == currentHeight + 1 :
840840 err := b .updateGraphWithClosedChannels (
@@ -991,7 +991,7 @@ func (b *Builder) updateGraphWithClosedChannels(
991991 // of the chain tip.
992992 blockHeight := chainUpdate .Height
993993
994- atomic . StoreUint32 ( & b .bestHeight , blockHeight )
994+ b .bestHeight . Store ( blockHeight )
995995 log .Infof ("Pruning channel graph using block %v (height=%v)" ,
996996 chainUpdate .Hash , blockHeight )
997997
@@ -1342,7 +1342,7 @@ func (b *Builder) processUpdate(msg interface{},
13421342 },
13431343 }
13441344 err = b .cfg .ChainView .UpdateFilter (
1345- filterUpdate , atomic . LoadUint32 ( & b .bestHeight ),
1345+ filterUpdate , b .bestHeight . Load ( ),
13461346 )
13471347 if err != nil {
13481348 return errors .Errorf ("unable to update chain " +
@@ -1658,7 +1658,7 @@ func (b *Builder) CurrentBlockHeight() (uint32, error) {
16581658// is synced to. This can differ from the above chain height if the goroutine
16591659// responsible for processing the blocks isn't yet up to speed.
16601660func (b * Builder ) SyncedHeight () uint32 {
1661- return atomic . LoadUint32 ( & b .bestHeight )
1661+ return b .bestHeight . Load ( )
16621662}
16631663
16641664// GetChannelByID return the channel by the channel id.
0 commit comments