@@ -41,11 +41,6 @@ type ChannelGraph struct {
41
41
started atomic.Bool
42
42
stopped atomic.Bool
43
43
44
- // cacheMu guards any writes to the graphCache. It should be held
45
- // across the DB write call and the graphCache update to make the
46
- // two updates as atomic as possible.
47
- cacheMu sync.Mutex
48
-
49
44
graphCache * GraphCache
50
45
51
46
* KVStore
@@ -283,9 +278,6 @@ func (c *ChannelGraph) ForEachNodeCached(cb func(node route.Vertex,
283
278
func (c * ChannelGraph ) AddLightningNode (node * models.LightningNode ,
284
279
op ... batch.SchedulerOption ) error {
285
280
286
- c .cacheMu .Lock ()
287
- defer c .cacheMu .Unlock ()
288
-
289
281
err := c .KVStore .AddLightningNode (node , op ... )
290
282
if err != nil {
291
283
return err
@@ -309,9 +301,6 @@ func (c *ChannelGraph) AddLightningNode(node *models.LightningNode,
309
301
// DeleteLightningNode starts a new database transaction to remove a vertex/node
310
302
// from the database according to the node's public key.
311
303
func (c * ChannelGraph ) DeleteLightningNode (nodePub route.Vertex ) error {
312
- c .cacheMu .Lock ()
313
- defer c .cacheMu .Unlock ()
314
-
315
304
err := c .KVStore .DeleteLightningNode (nodePub )
316
305
if err != nil {
317
306
return err
@@ -333,9 +322,6 @@ func (c *ChannelGraph) DeleteLightningNode(nodePub route.Vertex) error {
333
322
func (c * ChannelGraph ) AddChannelEdge (edge * models.ChannelEdgeInfo ,
334
323
op ... batch.SchedulerOption ) error {
335
324
336
- c .cacheMu .Lock ()
337
- defer c .cacheMu .Unlock ()
338
-
339
325
err := c .KVStore .AddChannelEdge (edge , op ... )
340
326
if err != nil {
341
327
return err
@@ -358,9 +344,6 @@ func (c *ChannelGraph) AddChannelEdge(edge *models.ChannelEdgeInfo,
358
344
// If the cache is enabled, the edge will be added back to the graph cache if
359
345
// we still have a record of this channel in the DB.
360
346
func (c * ChannelGraph ) MarkEdgeLive (chanID uint64 ) error {
361
- c .cacheMu .Lock ()
362
- defer c .cacheMu .Unlock ()
363
-
364
347
err := c .KVStore .MarkEdgeLive (chanID )
365
348
if err != nil {
366
349
return err
@@ -397,9 +380,6 @@ func (c *ChannelGraph) MarkEdgeLive(chanID uint64) error {
397
380
func (c * ChannelGraph ) DeleteChannelEdges (strictZombiePruning , markZombie bool ,
398
381
chanIDs ... uint64 ) error {
399
382
400
- c .cacheMu .Lock ()
401
- defer c .cacheMu .Unlock ()
402
-
403
383
infos , err := c .KVStore .DeleteChannelEdges (
404
384
strictZombiePruning , markZombie , chanIDs ... ,
405
385
)
@@ -429,9 +409,6 @@ func (c *ChannelGraph) DeleteChannelEdges(strictZombiePruning, markZombie bool,
429
409
func (c * ChannelGraph ) DisconnectBlockAtHeight (height uint32 ) (
430
410
[]* models.ChannelEdgeInfo , error ) {
431
411
432
- c .cacheMu .Lock ()
433
- defer c .cacheMu .Unlock ()
434
-
435
412
edges , err := c .KVStore .DisconnectBlockAtHeight (height )
436
413
if err != nil {
437
414
return nil , err
@@ -460,9 +437,6 @@ func (c *ChannelGraph) PruneGraph(spentOutputs []*wire.OutPoint,
460
437
blockHash * chainhash.Hash , blockHeight uint32 ) (
461
438
[]* models.ChannelEdgeInfo , error ) {
462
439
463
- c .cacheMu .Lock ()
464
- defer c .cacheMu .Unlock ()
465
-
466
440
edges , nodes , err := c .KVStore .PruneGraph (
467
441
spentOutputs , blockHash , blockHeight ,
468
442
)
@@ -505,9 +479,6 @@ func (c *ChannelGraph) PruneGraph(spentOutputs []*wire.OutPoint,
505
479
// that we only maintain a graph of reachable nodes. In the event that a pruned
506
480
// node gains more channels, it will be re-added back to the graph.
507
481
func (c * ChannelGraph ) PruneGraphNodes () error {
508
- c .cacheMu .Lock ()
509
- defer c .cacheMu .Unlock ()
510
-
511
482
nodes , err := c .KVStore .PruneGraphNodes ()
512
483
if err != nil {
513
484
return err
@@ -580,9 +551,6 @@ func (c *ChannelGraph) FilterKnownChanIDs(chansInfo []ChannelUpdateInfo,
580
551
func (c * ChannelGraph ) MarkEdgeZombie (chanID uint64 ,
581
552
pubKey1 , pubKey2 [33 ]byte ) error {
582
553
583
- c .cacheMu .Lock ()
584
- defer c .cacheMu .Unlock ()
585
-
586
554
err := c .KVStore .MarkEdgeZombie (chanID , pubKey1 , pubKey2 )
587
555
if err != nil {
588
556
return err
@@ -605,9 +573,6 @@ func (c *ChannelGraph) MarkEdgeZombie(chanID uint64,
605
573
func (c * ChannelGraph ) UpdateEdgePolicy (edge * models.ChannelEdgePolicy ,
606
574
op ... batch.SchedulerOption ) error {
607
575
608
- c .cacheMu .Lock ()
609
- defer c .cacheMu .Unlock ()
610
-
611
576
from , to , err := c .KVStore .UpdateEdgePolicy (edge , op ... )
612
577
if err != nil {
613
578
return err
0 commit comments