channeldb/graph: refactor UpdateEdgePolicy to use existing db transaction

This commit is contained in:
Wilmer Paulino committed 2018-09-04 18:31:37 -07:00
1 parent aa3e2b6ba4
commit 06344da62e
1 file changed
+9 -1
+9 -1
View File
@@ -1618,6 +1618,15 @@ func (c *ChannelGraph) UpdateEdgePolicy(edge *ChannelEdgePolicy) error {
return err return err
} }
return updateEdgePolicy(edges, edgeIndex, edge)
})
}
// updateEdgePolicy attempts to update an edge's policy within the relevant
// buckets using an existing database transaction.
func updateEdgePolicy(edges, edgeIndex *bolt.Bucket,
edge *ChannelEdgePolicy) error {
// Create the channelID key be converting the channel ID // Create the channelID key be converting the channel ID
// integer into a byte slice. // integer into a byte slice.
var chanID [8]byte var chanID [8]byte
@@ -1644,7 +1653,6 @@ func (c *ChannelGraph) UpdateEdgePolicy(edge *ChannelEdgePolicy) error {
// Finally, with the direction of the edge being updated // Finally, with the direction of the edge being updated
// identified, we update the on-disk edge representation. // identified, we update the on-disk edge representation.
return putChanEdgePolicy(edges, edge, fromNode, toNode) return putChanEdgePolicy(edges, edge, fromNode, toNode)
})
} }
// LightningNode represents an individual vertex/node within the channel graph. // LightningNode represents an individual vertex/node within the channel graph.