mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-08-30 23:53:41 +02:00
multi: remove the NodeRTx interface type
This commit is contained in:
@@ -10,6 +10,7 @@ import (
|
||||
"github.com/btcsuite/btcd/btcec/v2/ecdsa"
|
||||
"github.com/btcsuite/btcd/btcutil"
|
||||
graphdb "github.com/lightningnetwork/lnd/graph/db"
|
||||
"github.com/lightningnetwork/lnd/graph/db/models"
|
||||
"github.com/lightningnetwork/lnd/lnwire"
|
||||
"github.com/lightningnetwork/lnd/routing/route"
|
||||
)
|
||||
@@ -83,17 +84,17 @@ func (d *dbNode) Addrs() []net.Addr {
|
||||
func (d *databaseChannelGraph) ForEachNode(ctx context.Context,
|
||||
cb func(context.Context, Node) error, reset func()) error {
|
||||
|
||||
return d.db.ForEachNode(ctx, func(nodeTx graphdb.NodeRTx) error {
|
||||
return d.db.ForEachNode(ctx, func(n *models.LightningNode) error {
|
||||
// We'll skip over any node that doesn't have any advertised
|
||||
// addresses. As we won't be able to reach them to actually
|
||||
// open any channels.
|
||||
if len(nodeTx.Node().Addresses) == 0 {
|
||||
if len(n.Addresses) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
node := &dbNode{
|
||||
pub: nodeTx.Node().PubKeyBytes,
|
||||
addrs: nodeTx.Node().Addresses,
|
||||
pub: n.PubKeyBytes,
|
||||
addrs: n.Addresses,
|
||||
}
|
||||
|
||||
return cb(ctx, node)
|
||||
|
@@ -8,6 +8,7 @@ import (
|
||||
"github.com/btcsuite/btcd/btcutil"
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
graphdb "github.com/lightningnetwork/lnd/graph/db"
|
||||
"github.com/lightningnetwork/lnd/graph/db/models"
|
||||
"github.com/lightningnetwork/lnd/lnwire"
|
||||
"github.com/lightningnetwork/lnd/routing/route"
|
||||
)
|
||||
@@ -228,9 +229,9 @@ type GraphSource interface {
|
||||
// ForEachNode iterates through all the stored vertices/nodes in the
|
||||
// graph, executing the passed callback with each node encountered. If
|
||||
// the callback returns an error, then the transaction is aborted and
|
||||
// the iteration stops early. Any operations performed on the NodeTx
|
||||
// passed to the call-back are executed under the same read transaction.
|
||||
ForEachNode(context.Context, func(graphdb.NodeRTx) error, func()) error
|
||||
// the iteration stops early.
|
||||
ForEachNode(context.Context, func(*models.LightningNode) error,
|
||||
func()) error
|
||||
|
||||
// ForEachNodeCached is similar to ForEachNode, but it utilizes the
|
||||
// channel graph cache if one is available. It is less consistent than
|
||||
|
@@ -741,26 +741,3 @@ func (m *memChannelGraph) addRandNode() (*btcec.PublicKey, error) {
|
||||
|
||||
return newPub, nil
|
||||
}
|
||||
|
||||
type testNodeTx struct {
|
||||
db *testDBGraph
|
||||
node *models.LightningNode
|
||||
}
|
||||
|
||||
func (t *testNodeTx) Node() *models.LightningNode {
|
||||
return t.node
|
||||
}
|
||||
|
||||
func (t *testNodeTx) ForEachChannel(f func(*models.ChannelEdgeInfo,
|
||||
*models.ChannelEdgePolicy, *models.ChannelEdgePolicy) error) error {
|
||||
|
||||
return t.db.db.ForEachNodeChannel(context.Background(),
|
||||
t.node.PubKeyBytes, func(edge *models.ChannelEdgeInfo, policy1,
|
||||
policy2 *models.ChannelEdgePolicy) error {
|
||||
|
||||
return f(edge, policy1, policy2)
|
||||
}, func() {},
|
||||
)
|
||||
}
|
||||
|
||||
var _ graphdb.NodeRTx = (*testNodeTx)(nil)
|
||||
|
Reference in New Issue
Block a user