mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-04-09 04:38:06 +02:00
channeldb: extract AddNodeFeatures
Preparation for efficient graph cache loading where we don't iterate over the channels of each node in the network individually.
This commit is contained in:
parent
b8408a1484
commit
aff9685a61
@ -205,9 +205,8 @@ func (c *GraphCache) Stats() string {
|
||||
numChannels)
|
||||
}
|
||||
|
||||
// AddNode adds a graph node, including all the (directed) channels of that
|
||||
// node.
|
||||
func (c *GraphCache) AddNode(tx kvdb.RTx, node GraphCacheNode) error {
|
||||
// AddNodeFeatures adds a graph node and its features to the cache.
|
||||
func (c *GraphCache) AddNodeFeatures(node GraphCacheNode) {
|
||||
nodePubKey := node.PubKey()
|
||||
|
||||
// Only hold the lock for a short time. The `ForEachChannel()` below is
|
||||
@ -217,6 +216,12 @@ func (c *GraphCache) AddNode(tx kvdb.RTx, node GraphCacheNode) error {
|
||||
c.mtx.Lock()
|
||||
c.nodeFeatures[nodePubKey] = node.Features()
|
||||
c.mtx.Unlock()
|
||||
}
|
||||
|
||||
// AddNode adds a graph node, including all the (directed) channels of that
|
||||
// node.
|
||||
func (c *GraphCache) AddNode(tx kvdb.RTx, node GraphCacheNode) error {
|
||||
c.AddNodeFeatures(node)
|
||||
|
||||
return node.ForEachChannel(
|
||||
tx, func(tx kvdb.RTx, info *ChannelEdgeInfo,
|
||||
|
Loading…
x
Reference in New Issue
Block a user