Files
lnd/graph/db/models/cached_edge_info.go
Elle Mouton 3069a67b62 graph/db: let GraghCache.AddChannel take CachedEdgeInfo
Define a new CachedEdgeInfo type and let the graph cache's AddChannel
use this. This will let us later on (for the SQL impl of the graph db)
only load from the DB what we actually need for the graph cache.
2025-06-10 20:10:35 +02:00

34 lines
1.1 KiB
Go

package models
import "github.com/btcsuite/btcd/btcutil"
// CachedEdgeInfo is a struct that only caches the information of a
// ChannelEdgeInfo that we actually use for pathfinding and therefore need to
// store in the cache.
type CachedEdgeInfo struct {
// ChannelID is the unique channel ID for the channel. The first 3
// bytes are the block height, the next 3 the index within the block,
// and the last 2 bytes are the output index for the channel.
ChannelID uint64
// NodeKey1Bytes is the raw public key of the first node.
NodeKey1Bytes [33]byte
// NodeKey2Bytes is the raw public key of the second node.
NodeKey2Bytes [33]byte
// Capacity is the total capacity of the channel, this is determined by
// the value output in the outpoint that created this channel.
Capacity btcutil.Amount
}
// NewCachedEdge creates a new CachedEdgeInfo from the provided ChannelEdgeInfo.
func NewCachedEdge(edgeInfo *ChannelEdgeInfo) *CachedEdgeInfo {
return &CachedEdgeInfo{
ChannelID: edgeInfo.ChannelID,
NodeKey1Bytes: edgeInfo.NodeKey1Bytes,
NodeKey2Bytes: edgeInfo.NodeKey2Bytes,
Capacity: edgeInfo.Capacity,
}
}