@@ -109,8 +109,7 @@ type Builder struct {
109
109
started atomic.Bool
110
110
stopped atomic.Bool
111
111
112
- ntfnClientCounter atomic.Uint64
113
- bestHeight atomic.Uint32
112
+ bestHeight atomic.Uint32
114
113
115
114
cfg * Config
116
115
@@ -123,22 +122,6 @@ type Builder struct {
123
122
// of our currently known best chain are sent over.
124
123
staleBlocks <- chan * chainview.FilteredBlock
125
124
126
- // topologyUpdate is a channel that carries new topology updates
127
- // messages from outside the Builder to be processed by the
128
- // networkHandler.
129
- topologyUpdate chan any
130
-
131
- // topologyClients maps a client's unique notification ID to a
132
- // topologyClient client that contains its notification dispatch
133
- // channel.
134
- topologyClients * lnutils.SyncMap [uint64 , * topologyClient ]
135
-
136
- // ntfnClientUpdates is a channel that's used to send new updates to
137
- // topology notification clients to the Builder. Updates either
138
- // add a new notification client, or cancel notifications for an
139
- // existing client.
140
- ntfnClientUpdates chan * topologyClientUpdate
141
-
142
125
// channelEdgeMtx is a mutex we use to make sure we process only one
143
126
// ChannelEdgePolicy at a time for a given channelID, to ensure
144
127
// consistency between the various database accesses.
@@ -163,14 +146,11 @@ var _ ChannelGraphSource = (*Builder)(nil)
163
146
// NewBuilder constructs a new Builder.
164
147
func NewBuilder (cfg * Config ) (* Builder , error ) {
165
148
return & Builder {
166
- cfg : cfg ,
167
- topologyUpdate : make (chan any ),
168
- topologyClients : & lnutils.SyncMap [uint64 , * topologyClient ]{},
169
- ntfnClientUpdates : make (chan * topologyClientUpdate ),
170
- channelEdgeMtx : multimutex .NewMutex [uint64 ](),
171
- statTicker : ticker .New (defaultStatInterval ),
172
- stats : new (builderStats ),
173
- quit : make (chan struct {}),
149
+ cfg : cfg ,
150
+ channelEdgeMtx : multimutex .NewMutex [uint64 ](),
151
+ statTicker : ticker .New (defaultStatInterval ),
152
+ stats : new (builderStats ),
153
+ quit : make (chan struct {}),
174
154
}, nil
175
155
}
176
156
@@ -656,28 +636,6 @@ func (b *Builder) pruneZombieChans() error {
656
636
return nil
657
637
}
658
638
659
- // handleTopologyUpdate is responsible for sending any topology changes
660
- // notifications to registered clients.
661
- //
662
- // NOTE: must be run inside goroutine.
663
- func (b * Builder ) handleTopologyUpdate (update any ) {
664
- defer b .wg .Done ()
665
-
666
- topChange := & TopologyChange {}
667
- err := addToTopologyChange (b .cfg .Graph , topChange , update )
668
- if err != nil {
669
- log .Errorf ("unable to update topology change notification: %v" ,
670
- err )
671
- return
672
- }
673
-
674
- if topChange .isEmpty () {
675
- return
676
- }
677
-
678
- b .notifyTopologyChange (topChange )
679
- }
680
-
681
639
// networkHandler is the primary goroutine for the Builder. The roles of
682
640
// this goroutine include answering queries related to the state of the
683
641
// network, pruning the graph on new block notification, applying network
@@ -701,16 +659,6 @@ func (b *Builder) networkHandler() {
701
659
}
702
660
703
661
select {
704
- // A new fully validated topology update has just arrived.
705
- // We'll notify any registered clients.
706
- case update := <- b .topologyUpdate :
707
- b .wg .Add (1 )
708
- go b .handleTopologyUpdate (update )
709
-
710
- // TODO(roasbeef): remove all unconnected vertexes
711
- // after N blocks pass with no corresponding
712
- // announcements.
713
-
714
662
case chainUpdate , ok := <- b .staleBlocks :
715
663
// If the channel has been closed, then this indicates
716
664
// the daemon is shutting down, so we exit ourselves.
@@ -783,31 +731,6 @@ func (b *Builder) networkHandler() {
783
731
" processed." , chainUpdate .Height )
784
732
}
785
733
786
- // A new notification client update has arrived. We're either
787
- // gaining a new client, or cancelling notifications for an
788
- // existing client.
789
- case ntfnUpdate := <- b .ntfnClientUpdates :
790
- clientID := ntfnUpdate .clientID
791
-
792
- if ntfnUpdate .cancel {
793
- client , ok := b .topologyClients .LoadAndDelete (
794
- clientID ,
795
- )
796
- if ok {
797
- close (client .exit )
798
- client .wg .Wait ()
799
-
800
- close (client .ntfnChan )
801
- }
802
-
803
- continue
804
- }
805
-
806
- b .topologyClients .Store (clientID , & topologyClient {
807
- ntfnChan : ntfnUpdate .ntfnChan ,
808
- exit : make (chan struct {}),
809
- })
810
-
811
734
// The graph prune ticker has ticked, so we'll examine the
812
735
// state of the known graph to filter out any zombie channels
813
736
// for pruning.
@@ -934,16 +857,6 @@ func (b *Builder) updateGraphWithClosedChannels(
934
857
log .Infof ("Block %v (height=%v) closed %v channels" , chainUpdate .Hash ,
935
858
blockHeight , len (chansClosed ))
936
859
937
- if len (chansClosed ) == 0 {
938
- return err
939
- }
940
-
941
- // Notify all currently registered clients of the newly closed channels.
942
- closeSummaries := createCloseSummaries (blockHeight , chansClosed ... )
943
- b .notifyTopologyChange (& TopologyChange {
944
- ClosedChannels : closeSummaries ,
945
- })
946
-
947
860
return nil
948
861
}
949
862
@@ -1073,12 +986,6 @@ func (b *Builder) AddNode(node *models.LightningNode,
1073
986
return err
1074
987
}
1075
988
1076
- select {
1077
- case b .topologyUpdate <- node :
1078
- case <- b .quit :
1079
- return ErrGraphBuilderShuttingDown
1080
- }
1081
-
1082
989
return nil
1083
990
}
1084
991
@@ -1129,12 +1036,6 @@ func (b *Builder) AddEdge(edge *models.ChannelEdgeInfo,
1129
1036
return err
1130
1037
}
1131
1038
1132
- select {
1133
- case b .topologyUpdate <- edge :
1134
- case <- b .quit :
1135
- return ErrGraphBuilderShuttingDown
1136
- }
1137
-
1138
1039
return nil
1139
1040
}
1140
1041
@@ -1242,12 +1143,6 @@ func (b *Builder) UpdateEdge(update *models.ChannelEdgePolicy,
1242
1143
return err
1243
1144
}
1244
1145
1245
- select {
1246
- case b .topologyUpdate <- update :
1247
- case <- b .quit :
1248
- return ErrGraphBuilderShuttingDown
1249
- }
1250
-
1251
1146
return nil
1252
1147
}
1253
1148
0 commit comments