mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-11-18 10:06:51 +01:00
netann+lnd: add netann.ChannelGraph to the GraphSource interface
And let DBSource implement it.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package netann
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"sync"
|
||||
"time"
|
||||
@@ -653,8 +654,12 @@ func (m *ChanStatusManager) signAndSendNextUpdate(outpoint wire.OutPoint,
|
||||
func (m *ChanStatusManager) fetchLastChanUpdateByOutPoint(op wire.OutPoint) (
|
||||
*lnwire.ChannelUpdate1, bool, error) {
|
||||
|
||||
ctx := context.TODO()
|
||||
|
||||
// Get the edge info and policies for this channel from the graph.
|
||||
info, edge1, edge2, err := m.cfg.Graph.FetchChannelEdgesByOutpoint(&op)
|
||||
info, edge1, edge2, err := m.cfg.Graph.FetchChannelEdgesByOutpoint(
|
||||
ctx, &op,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, false, err
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package netann_test
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"crypto/rand"
|
||||
"encoding/binary"
|
||||
"fmt"
|
||||
@@ -160,7 +161,7 @@ func (g *mockGraph) FetchAllOpenChannels() ([]*channeldb.OpenChannel, error) {
|
||||
return g.chans(), nil
|
||||
}
|
||||
|
||||
func (g *mockGraph) FetchChannelEdgesByOutpoint(
|
||||
func (g *mockGraph) FetchChannelEdgesByOutpoint(ctx context.Context,
|
||||
op *wire.OutPoint) (*models.ChannelEdgeInfo,
|
||||
*models.ChannelEdgePolicy, *models.ChannelEdgePolicy, error) {
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package netann
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
"github.com/lightningnetwork/lnd/channeldb"
|
||||
"github.com/lightningnetwork/lnd/graph/db/models"
|
||||
@@ -19,6 +21,7 @@ type DB interface {
|
||||
type ChannelGraph interface {
|
||||
// FetchChannelEdgesByOutpoint returns the channel edge info and most
|
||||
// recent channel edge policies for a given outpoint.
|
||||
FetchChannelEdgesByOutpoint(*wire.OutPoint) (*models.ChannelEdgeInfo,
|
||||
*models.ChannelEdgePolicy, *models.ChannelEdgePolicy, error)
|
||||
FetchChannelEdgesByOutpoint(context.Context, *wire.OutPoint) (
|
||||
*models.ChannelEdgeInfo, *models.ChannelEdgePolicy,
|
||||
*models.ChannelEdgePolicy, error)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user