Merge pull request #10129 from ellemouton/graphPerf9

[8] graph/db: use batch loading for various graph SQL methods
This commit is contained in:
Elle
2025-08-08 10:22:51 +02:00
committed by GitHub
5 changed files with 504 additions and 226 deletions

View File

@@ -37,3 +37,127 @@ func makeQueryParams(numTotalArgs, numListArgs int) string {
return b.String()
}
// ChannelAndNodes is an interface that provides access to a channel and its
// two nodes.
type ChannelAndNodes interface {
// Channel returns the GraphChannel associated with this interface.
Channel() GraphChannel
// Node1 returns the first GraphNode associated with this channel.
Node1() GraphNode
// Node2 returns the second GraphNode associated with this channel.
Node2() GraphNode
}
// Channel returns the GraphChannel associated with this interface.
//
// NOTE: This method is part of the ChannelAndNodes interface.
func (r GetChannelsByPolicyLastUpdateRangeRow) Channel() GraphChannel {
return r.GraphChannel
}
// Node1 returns the first GraphNode associated with this channel.
//
// NOTE: This method is part of the ChannelAndNodes interface.
func (r GetChannelsByPolicyLastUpdateRangeRow) Node1() GraphNode {
return r.GraphNode
}
// Node2 returns the second GraphNode associated with this channel.
//
// NOTE: This method is part of the ChannelAndNodes interface.
func (r GetChannelsByPolicyLastUpdateRangeRow) Node2() GraphNode {
return r.GraphNode_2
}
// ChannelAndNodeIDs is an interface that provides access to a channel and its
// two node public keys.
type ChannelAndNodeIDs interface {
// Channel returns the GraphChannel associated with this interface.
Channel() GraphChannel
// Node1Pub returns the public key of the first node as a byte slice.
Node1Pub() []byte
// Node2Pub returns the public key of the second node as a byte slice.
Node2Pub() []byte
}
// Channel returns the GraphChannel associated with this interface.
//
// NOTE: This method is part of the ChannelAndNodeIDs interface.
func (r GetChannelsBySCIDWithPoliciesRow) Channel() GraphChannel {
return r.GraphChannel
}
// Node1Pub returns the public key of the first node as a byte slice.
//
// NOTE: This method is part of the ChannelAndNodeIDs interface.
func (r GetChannelsBySCIDWithPoliciesRow) Node1Pub() []byte {
return r.GraphNode.PubKey
}
// Node2Pub returns the public key of the second node as a byte slice.
//
// NOTE: This method is part of the ChannelAndNodeIDs interface.
func (r GetChannelsBySCIDWithPoliciesRow) Node2Pub() []byte {
return r.GraphNode_2.PubKey
}
// Node1 returns the first GraphNode associated with this channel.
//
// NOTE: This method is part of the ChannelAndNodes interface.
func (r GetChannelsBySCIDWithPoliciesRow) Node1() GraphNode {
return r.GraphNode
}
// Node2 returns the second GraphNode associated with this channel.
//
// NOTE: This method is part of the ChannelAndNodes interface.
func (r GetChannelsBySCIDWithPoliciesRow) Node2() GraphNode {
return r.GraphNode_2
}
// Channel returns the GraphChannel associated with this interface.
//
// NOTE: This method is part of the ChannelAndNodeIDs interface.
func (r GetChannelsByOutpointsRow) Channel() GraphChannel {
return r.GraphChannel
}
// Node1Pub returns the public key of the first node as a byte slice.
//
// NOTE: This method is part of the ChannelAndNodeIDs interface.
func (r GetChannelsByOutpointsRow) Node1Pub() []byte {
return r.Node1Pubkey
}
// Node2Pub returns the public key of the second node as a byte slice.
//
// NOTE: This method is part of the ChannelAndNodeIDs interface.
func (r GetChannelsByOutpointsRow) Node2Pub() []byte {
return r.Node2Pubkey
}
// Channel returns the GraphChannel associated with this interface.
//
// NOTE: This method is part of the ChannelAndNodeIDs interface.
func (r GetChannelsBySCIDRangeRow) Channel() GraphChannel {
return r.GraphChannel
}
// Node1Pub returns the public key of the first node as a byte slice.
//
// NOTE: This method is part of the ChannelAndNodeIDs interface.
func (r GetChannelsBySCIDRangeRow) Node1Pub() []byte {
return r.Node1PubKey
}
// Node2Pub returns the public key of the second node as a byte slice.
//
// NOTE: This method is part of the ChannelAndNodeIDs interface.
func (r GetChannelsBySCIDRangeRow) Node2Pub() []byte {
return r.Node2PubKey
}