@@ -435,6 +435,10 @@ func (s *SQLStore) DeleteNode(ctx context.Context,
435435 return fmt .Errorf ("unable to delete node: %w" , err )
436436 }
437437
438+ s .cacheMu .Lock ()
439+ s .removePublicNodeCache (pubKey )
440+ s .cacheMu .Unlock ()
441+
438442 return nil
439443}
440444
@@ -734,6 +738,10 @@ func (s *SQLStore) AddChannelEdge(ctx context.Context,
734738 default :
735739 s .rejectCache .remove (edge .ChannelID )
736740 s .chanCache .remove (edge .ChannelID )
741+ s .removePublicNodeCache (
742+ edge .NodeKey1Bytes , edge .NodeKey2Bytes ,
743+ )
744+
737745 return nil
738746 }
739747 },
@@ -1740,6 +1748,7 @@ func (s *SQLStore) MarkEdgeZombie(chanID uint64,
17401748
17411749 s .rejectCache .remove (chanID )
17421750 s .chanCache .remove (chanID )
1751+ s .removePublicNodeCache (pubKey1 , pubKey2 )
17431752
17441753 return nil
17451754}
@@ -1965,6 +1974,14 @@ func (s *SQLStore) DeleteChannelEdges(strictZombiePruning, markZombie bool,
19651974 s .chanCache .remove (chanID )
19661975 }
19671976
1977+ var pubkeys [][33 ]byte
1978+ for _ , edge := range edges {
1979+ pubkeys = append (
1980+ pubkeys , edge .NodeKey1Bytes , edge .NodeKey2Bytes ,
1981+ )
1982+ }
1983+ s .removePublicNodeCache (pubkeys ... )
1984+
19681985 return edges , nil
19691986}
19701987
@@ -2695,6 +2712,9 @@ func (s *SQLStore) PruneGraph(spentOutputs []*wire.OutPoint,
26952712 for _ , channel := range closedChans {
26962713 s .rejectCache .remove (channel .ChannelID )
26972714 s .chanCache .remove (channel .ChannelID )
2715+ s .removePublicNodeCache (
2716+ channel .NodeKey1Bytes , channel .NodeKey2Bytes ,
2717+ )
26982718 }
26992719
27002720 return closedChans , prunedNodes , nil
@@ -2962,6 +2982,9 @@ func (s *SQLStore) DisconnectBlockAtHeight(height uint32) (
29622982 for _ , channel := range removedChans {
29632983 s .rejectCache .remove (channel .ChannelID )
29642984 s .chanCache .remove (channel .ChannelID )
2985+ s .removePublicNodeCache (
2986+ channel .NodeKey1Bytes , channel .NodeKey2Bytes ,
2987+ )
29652988 }
29662989
29672990 return removedChans , nil
@@ -5784,3 +5807,11 @@ func handleZombieMarking(ctx context.Context, db SQLQueries,
57845807 },
57855808 )
57865809}
5810+
5811+ // removePublicNodeCache takes in a list of public keys and remove the
5812+ // corresponding nodes info from the cache if it exists.
5813+ func (s * SQLStore ) removePublicNodeCache (pubkeys ... [33 ]byte ) {
5814+ for _ , pubkey := range pubkeys {
5815+ s .publicNodeCache .Delete (pubkey )
5816+ }
5817+ }
0 commit comments