Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 0 additions & 35 deletions graph/db/graph.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,6 @@ type ChannelGraph struct {
started atomic.Bool
stopped atomic.Bool

// cacheMu guards any writes to the graphCache. It should be held
// across the DB write call and the graphCache update to make the
// two updates as atomic as possible.
cacheMu sync.Mutex

graphCache *GraphCache

*KVStore
Expand Down Expand Up @@ -283,9 +278,6 @@ func (c *ChannelGraph) ForEachNodeCached(cb func(node route.Vertex,
func (c *ChannelGraph) AddLightningNode(node *models.LightningNode,
op ...batch.SchedulerOption) error {

c.cacheMu.Lock()
defer c.cacheMu.Unlock()

err := c.KVStore.AddLightningNode(node, op...)
if err != nil {
return err
Expand All @@ -309,9 +301,6 @@ func (c *ChannelGraph) AddLightningNode(node *models.LightningNode,
// DeleteLightningNode starts a new database transaction to remove a vertex/node
// from the database according to the node's public key.
func (c *ChannelGraph) DeleteLightningNode(nodePub route.Vertex) error {
c.cacheMu.Lock()
defer c.cacheMu.Unlock()

err := c.KVStore.DeleteLightningNode(nodePub)
if err != nil {
return err
Expand All @@ -333,9 +322,6 @@ func (c *ChannelGraph) DeleteLightningNode(nodePub route.Vertex) error {
func (c *ChannelGraph) AddChannelEdge(edge *models.ChannelEdgeInfo,
op ...batch.SchedulerOption) error {

c.cacheMu.Lock()
defer c.cacheMu.Unlock()

err := c.KVStore.AddChannelEdge(edge, op...)
if err != nil {
return err
Expand All @@ -358,9 +344,6 @@ func (c *ChannelGraph) AddChannelEdge(edge *models.ChannelEdgeInfo,
// If the cache is enabled, the edge will be added back to the graph cache if
// we still have a record of this channel in the DB.
func (c *ChannelGraph) MarkEdgeLive(chanID uint64) error {
c.cacheMu.Lock()
defer c.cacheMu.Unlock()

err := c.KVStore.MarkEdgeLive(chanID)
if err != nil {
return err
Expand Down Expand Up @@ -397,9 +380,6 @@ func (c *ChannelGraph) MarkEdgeLive(chanID uint64) error {
func (c *ChannelGraph) DeleteChannelEdges(strictZombiePruning, markZombie bool,
chanIDs ...uint64) error {

c.cacheMu.Lock()
defer c.cacheMu.Unlock()

infos, err := c.KVStore.DeleteChannelEdges(
strictZombiePruning, markZombie, chanIDs...,
)
Expand Down Expand Up @@ -429,9 +409,6 @@ func (c *ChannelGraph) DeleteChannelEdges(strictZombiePruning, markZombie bool,
func (c *ChannelGraph) DisconnectBlockAtHeight(height uint32) (
[]*models.ChannelEdgeInfo, error) {

c.cacheMu.Lock()
defer c.cacheMu.Unlock()

edges, err := c.KVStore.DisconnectBlockAtHeight(height)
if err != nil {
return nil, err
Expand Down Expand Up @@ -460,9 +437,6 @@ func (c *ChannelGraph) PruneGraph(spentOutputs []*wire.OutPoint,
blockHash *chainhash.Hash, blockHeight uint32) (
[]*models.ChannelEdgeInfo, error) {

c.cacheMu.Lock()
defer c.cacheMu.Unlock()

edges, nodes, err := c.KVStore.PruneGraph(
spentOutputs, blockHash, blockHeight,
)
Expand Down Expand Up @@ -505,9 +479,6 @@ func (c *ChannelGraph) PruneGraph(spentOutputs []*wire.OutPoint,
// that we only maintain a graph of reachable nodes. In the event that a pruned
// node gains more channels, it will be re-added back to the graph.
func (c *ChannelGraph) PruneGraphNodes() error {
c.cacheMu.Lock()
defer c.cacheMu.Unlock()

nodes, err := c.KVStore.PruneGraphNodes()
if err != nil {
return err
Expand Down Expand Up @@ -580,9 +551,6 @@ func (c *ChannelGraph) FilterKnownChanIDs(chansInfo []ChannelUpdateInfo,
func (c *ChannelGraph) MarkEdgeZombie(chanID uint64,
pubKey1, pubKey2 [33]byte) error {

c.cacheMu.Lock()
defer c.cacheMu.Unlock()

err := c.KVStore.MarkEdgeZombie(chanID, pubKey1, pubKey2)
if err != nil {
return err
Expand All @@ -605,9 +573,6 @@ func (c *ChannelGraph) MarkEdgeZombie(chanID uint64,
func (c *ChannelGraph) UpdateEdgePolicy(edge *models.ChannelEdgePolicy,
op ...batch.SchedulerOption) error {

c.cacheMu.Lock()
defer c.cacheMu.Unlock()

from, to, err := c.KVStore.UpdateEdgePolicy(edge, op...)
if err != nil {
return err
Expand Down
Loading