multi: move DB schemas to channeldb/models
This commit moves the ChannelEdgePolicy, ChannelEdgeInfo, ChanelAuthProof and CachedEdgePolicy structs to the `channeldb/models` package.
This commit is contained in:
45 files changed
+1028
-968
No files matched your search
+5
-5
@@ -5,7 +5,7 @@ import (
|
||||
"fmt"
|
||||
|
||||
sphinx "github.com/lightningnetwork/lightning-onion"
|
||||
"github.com/lightningnetwork/lnd/channeldb"
|
||||
"github.com/lightningnetwork/lnd/channeldb/models"
|
||||
"github.com/lightningnetwork/lnd/lnwire"
|
||||
"github.com/lightningnetwork/lnd/routing/route"
|
||||
)
|
||||
@@ -99,7 +99,7 @@ func (b *BlindedPayment) toRouteHints() RouteHints {
|
||||
|
||||
hintCount := len(b.BlindedPath.BlindedHops) - 1
|
||||
hints := make(
|
||||
map[route.Vertex][]*channeldb.CachedEdgePolicy, hintCount,
|
||||
map[route.Vertex][]*models.CachedEdgePolicy, hintCount,
|
||||
)
|
||||
|
||||
// Start at the unblinded introduction node, because our pathfinding
|
||||
@@ -116,7 +116,7 @@ func (b *BlindedPayment) toRouteHints() RouteHints {
|
||||
// will ensure that pathfinding provides sufficient fees/delay for the
|
||||
// blinded portion to the introduction node.
|
||||
firstBlindedHop := b.BlindedPath.BlindedHops[1].BlindedNodePub
|
||||
hints[fromNode] = []*channeldb.CachedEdgePolicy{
|
||||
hints[fromNode] = []*models.CachedEdgePolicy{
|
||||
{
|
||||
TimeLockDelta: b.CltvExpiryDelta,
|
||||
MinHTLC: lnwire.MilliSatoshi(b.HtlcMinimum),
|
||||
@@ -156,14 +156,14 @@ func (b *BlindedPayment) toRouteHints() RouteHints {
|
||||
b.BlindedPath.BlindedHops[nextHopIdx].BlindedNodePub,
|
||||
)
|
||||
|
||||
hint := &channeldb.CachedEdgePolicy{
|
||||
hint := &models.CachedEdgePolicy{
|
||||
ToNodePubKey: func() route.Vertex {
|
||||
return nextNode
|
||||
},
|
||||
ToNodeFeatures: features,
|
||||
}
|
||||
|
||||
hints[fromNode] = []*channeldb.CachedEdgePolicy{
|
||||
hints[fromNode] = []*models.CachedEdgePolicy{
|
||||
hint,
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -3,7 +3,7 @@ package routing
|
||||
import (
|
||||
"container/heap"
|
||||
|
||||
"github.com/lightningnetwork/lnd/channeldb"
|
||||
"github.com/lightningnetwork/lnd/channeldb/models"
|
||||
"github.com/lightningnetwork/lnd/lnwire"
|
||||
"github.com/lightningnetwork/lnd/routing/route"
|
||||
)
|
||||
@@ -39,7 +39,7 @@ type nodeWithDist struct {
|
||||
weight int64
|
||||
|
||||
// nextHop is the edge this route comes from.
|
||||
nextHop *channeldb.CachedEdgePolicy
|
||||
nextHop *models.CachedEdgePolicy
|
||||
|
||||
// routingInfoSize is the total size requirement for the payloads field
|
||||
// in the onion packet from this hop towards the final destination.
|
||||
|
||||
@@ -31,8 +31,8 @@ type Manager struct {
|
||||
// ForAllOutgoingChannels is required to iterate over all our local
|
||||
// channels.
|
||||
ForAllOutgoingChannels func(cb func(kvdb.RTx,
|
||||
*channeldb.ChannelEdgeInfo,
|
||||
*channeldb.ChannelEdgePolicy) error) error
|
||||
*models.ChannelEdgeInfo,
|
||||
*models.ChannelEdgePolicy) error) error
|
||||
|
||||
// FetchChannel is used to query local channel parameters. Optionally an
|
||||
// existing db tx can be supplied.
|
||||
@@ -73,8 +73,8 @@ func (r *Manager) UpdatePolicy(newSchema routing.ChannelPolicy,
|
||||
// otherwise we'll collect them all.
|
||||
err := r.ForAllOutgoingChannels(func(
|
||||
tx kvdb.RTx,
|
||||
info *channeldb.ChannelEdgeInfo,
|
||||
edge *channeldb.ChannelEdgePolicy) error {
|
||||
info *models.ChannelEdgeInfo,
|
||||
edge *models.ChannelEdgePolicy) error {
|
||||
|
||||
// If we have a channel filter, and this channel isn't a part
|
||||
// of it, then we'll skip it.
|
||||
@@ -172,7 +172,7 @@ func (r *Manager) UpdatePolicy(newSchema routing.ChannelPolicy,
|
||||
|
||||
// updateEdge updates the given edge with the new schema.
|
||||
func (r *Manager) updateEdge(tx kvdb.RTx, chanPoint wire.OutPoint,
|
||||
edge *channeldb.ChannelEdgePolicy,
|
||||
edge *models.ChannelEdgePolicy,
|
||||
newSchema routing.ChannelPolicy) error {
|
||||
|
||||
// Update forwarding fee scheme and required time lock delta.
|
||||
|
||||
@@ -22,7 +22,7 @@ func TestManager(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
type channel struct {
|
||||
edgeInfo *channeldb.ChannelEdgeInfo
|
||||
edgeInfo *models.ChannelEdgeInfo
|
||||
}
|
||||
|
||||
var (
|
||||
@@ -44,7 +44,7 @@ func TestManager(t *testing.T) {
|
||||
MaxHTLC: 5000,
|
||||
}
|
||||
|
||||
currentPolicy := channeldb.ChannelEdgePolicy{
|
||||
currentPolicy := models.ChannelEdgePolicy{
|
||||
MinHTLC: minHTLC,
|
||||
MessageFlags: lnwire.ChanUpdateRequiredMaxHtlc,
|
||||
}
|
||||
@@ -107,8 +107,8 @@ func TestManager(t *testing.T) {
|
||||
}
|
||||
|
||||
forAllOutgoingChannels := func(cb func(kvdb.RTx,
|
||||
*channeldb.ChannelEdgeInfo,
|
||||
*channeldb.ChannelEdgePolicy) error) error {
|
||||
*models.ChannelEdgeInfo,
|
||||
*models.ChannelEdgePolicy) error) error {
|
||||
|
||||
for _, c := range channelSet {
|
||||
if err := cb(nil, c.edgeInfo, ¤tPolicy); err != nil {
|
||||
@@ -152,7 +152,7 @@ func TestManager(t *testing.T) {
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
currentPolicy channeldb.ChannelEdgePolicy
|
||||
currentPolicy models.ChannelEdgePolicy
|
||||
newPolicy routing.ChannelPolicy
|
||||
channelSet []channel
|
||||
specifiedChanPoints []wire.OutPoint
|
||||
@@ -166,7 +166,7 @@ func TestManager(t *testing.T) {
|
||||
newPolicy: newPolicy,
|
||||
channelSet: []channel{
|
||||
{
|
||||
edgeInfo: &channeldb.ChannelEdgeInfo{
|
||||
edgeInfo: &models.ChannelEdgeInfo{
|
||||
Capacity: chanCap,
|
||||
ChannelPoint: chanPointValid,
|
||||
},
|
||||
@@ -183,7 +183,7 @@ func TestManager(t *testing.T) {
|
||||
newPolicy: newPolicy,
|
||||
channelSet: []channel{
|
||||
{
|
||||
edgeInfo: &channeldb.ChannelEdgeInfo{
|
||||
edgeInfo: &models.ChannelEdgeInfo{
|
||||
Capacity: chanCap,
|
||||
ChannelPoint: chanPointValid,
|
||||
},
|
||||
@@ -200,7 +200,7 @@ func TestManager(t *testing.T) {
|
||||
newPolicy: newPolicy,
|
||||
channelSet: []channel{
|
||||
{
|
||||
edgeInfo: &channeldb.ChannelEdgeInfo{
|
||||
edgeInfo: &models.ChannelEdgeInfo{
|
||||
Capacity: chanCap,
|
||||
ChannelPoint: chanPointValid,
|
||||
},
|
||||
@@ -221,7 +221,7 @@ func TestManager(t *testing.T) {
|
||||
newPolicy: noMaxHtlcPolicy,
|
||||
channelSet: []channel{
|
||||
{
|
||||
edgeInfo: &channeldb.ChannelEdgeInfo{
|
||||
edgeInfo: &models.ChannelEdgeInfo{
|
||||
Capacity: chanCap,
|
||||
ChannelPoint: chanPointValid,
|
||||
},
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"github.com/btcsuite/btcd/btcec/v2"
|
||||
"github.com/btcsuite/btcd/btcutil"
|
||||
"github.com/lightningnetwork/lnd/channeldb"
|
||||
"github.com/lightningnetwork/lnd/channeldb/models"
|
||||
"github.com/lightningnetwork/lnd/lnwire"
|
||||
"github.com/lightningnetwork/lnd/routing/route"
|
||||
)
|
||||
@@ -193,7 +194,7 @@ func (m *mockGraph) forEachNodeChannel(nodePub route.Vertex,
|
||||
OtherNode: peer,
|
||||
Capacity: channel.capacity,
|
||||
OutPolicySet: true,
|
||||
InPolicy: &channeldb.CachedEdgePolicy{
|
||||
InPolicy: &models.CachedEdgePolicy{
|
||||
ChannelID: channel.id,
|
||||
ToNodePubKey: func() route.Vertex {
|
||||
return nodePub
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"github.com/btcsuite/btcd/btcutil"
|
||||
"github.com/go-errors/errors"
|
||||
"github.com/lightningnetwork/lnd/channeldb"
|
||||
"github.com/lightningnetwork/lnd/channeldb/models"
|
||||
"github.com/lightningnetwork/lnd/htlcswitch"
|
||||
"github.com/lightningnetwork/lnd/lntypes"
|
||||
"github.com/lightningnetwork/lnd/lnwire"
|
||||
@@ -174,13 +175,13 @@ func (m *mockPaymentSessionOld) RequestRoute(_, _ lnwire.MilliSatoshi,
|
||||
}
|
||||
|
||||
func (m *mockPaymentSessionOld) UpdateAdditionalEdge(_ *lnwire.ChannelUpdate,
|
||||
_ *btcec.PublicKey, _ *channeldb.CachedEdgePolicy) bool {
|
||||
_ *btcec.PublicKey, _ *models.CachedEdgePolicy) bool {
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (m *mockPaymentSessionOld) GetAdditionalEdgePolicy(_ *btcec.PublicKey,
|
||||
_ uint64) *channeldb.CachedEdgePolicy {
|
||||
_ uint64) *models.CachedEdgePolicy {
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -676,17 +677,17 @@ func (m *mockPaymentSession) RequestRoute(maxAmt, feeLimit lnwire.MilliSatoshi,
|
||||
}
|
||||
|
||||
func (m *mockPaymentSession) UpdateAdditionalEdge(msg *lnwire.ChannelUpdate,
|
||||
pubKey *btcec.PublicKey, policy *channeldb.CachedEdgePolicy) bool {
|
||||
pubKey *btcec.PublicKey, policy *models.CachedEdgePolicy) bool {
|
||||
|
||||
args := m.Called(msg, pubKey, policy)
|
||||
return args.Bool(0)
|
||||
}
|
||||
|
||||
func (m *mockPaymentSession) GetAdditionalEdgePolicy(pubKey *btcec.PublicKey,
|
||||
channelID uint64) *channeldb.CachedEdgePolicy {
|
||||
channelID uint64) *models.CachedEdgePolicy {
|
||||
|
||||
args := m.Called(pubKey, channelID)
|
||||
return args.Get(0).(*channeldb.CachedEdgePolicy)
|
||||
return args.Get(0).(*models.CachedEdgePolicy)
|
||||
}
|
||||
|
||||
type mockControlTower struct {
|
||||
|
||||
@@ -12,6 +12,7 @@ import (
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
"github.com/go-errors/errors"
|
||||
"github.com/lightningnetwork/lnd/channeldb"
|
||||
"github.com/lightningnetwork/lnd/channeldb/models"
|
||||
"github.com/lightningnetwork/lnd/lnwire"
|
||||
)
|
||||
|
||||
@@ -212,7 +213,7 @@ type ClosedChanSummary struct {
|
||||
// createCloseSummaries takes in a slice of channels closed at the target block
|
||||
// height and creates a slice of summaries which of each channel closure.
|
||||
func createCloseSummaries(blockHeight uint32,
|
||||
closedChans ...*channeldb.ChannelEdgeInfo) []*ClosedChanSummary {
|
||||
closedChans ...*models.ChannelEdgeInfo) []*ClosedChanSummary {
|
||||
|
||||
closeSummaries := make([]*ClosedChanSummary, len(closedChans))
|
||||
for i, closedChan := range closedChans {
|
||||
@@ -333,12 +334,12 @@ func addToTopologyChange(graph *channeldb.ChannelGraph, update *TopologyChange,
|
||||
|
||||
// We ignore initial channel announcements as we'll only send out
|
||||
// updates once the individual edges themselves have been updated.
|
||||
case *channeldb.ChannelEdgeInfo:
|
||||
case *models.ChannelEdgeInfo:
|
||||
return nil
|
||||
|
||||
// Any new ChannelUpdateAnnouncements will generate a corresponding
|
||||
// ChannelEdgeUpdate notification.
|
||||
case *channeldb.ChannelEdgePolicy:
|
||||
case *models.ChannelEdgePolicy:
|
||||
// We'll need to fetch the edge's information from the database
|
||||
// in order to get the information concerning which nodes are
|
||||
// being connected.
|
||||
|
||||
@@ -16,6 +16,7 @@ import (
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
"github.com/go-errors/errors"
|
||||
"github.com/lightningnetwork/lnd/channeldb"
|
||||
"github.com/lightningnetwork/lnd/channeldb/models"
|
||||
"github.com/lightningnetwork/lnd/input"
|
||||
"github.com/lightningnetwork/lnd/lnwallet"
|
||||
"github.com/lightningnetwork/lnd/lnwallet/btcwallet"
|
||||
@@ -74,9 +75,9 @@ func createTestNode() (*channeldb.LightningNode, error) {
|
||||
}
|
||||
|
||||
func randEdgePolicy(chanID *lnwire.ShortChannelID,
|
||||
node *channeldb.LightningNode) *channeldb.ChannelEdgePolicy {
|
||||
node *channeldb.LightningNode) *models.ChannelEdgePolicy {
|
||||
|
||||
return &channeldb.ChannelEdgePolicy{
|
||||
return &models.ChannelEdgePolicy{
|
||||
SigBytes: testSig.Serialize(),
|
||||
ChannelID: chanID.ToUint64(),
|
||||
LastUpdate: time.Unix(int64(prand.Int31()), 0),
|
||||
@@ -431,11 +432,11 @@ func TestEdgeUpdateNotification(t *testing.T) {
|
||||
|
||||
// Finally, to conclude our test set up, we'll create a channel
|
||||
// update to announce the created channel between the two nodes.
|
||||
edge := &channeldb.ChannelEdgeInfo{
|
||||
edge := &models.ChannelEdgeInfo{
|
||||
ChannelID: chanID.ToUint64(),
|
||||
NodeKey1Bytes: node1.PubKeyBytes,
|
||||
NodeKey2Bytes: node2.PubKeyBytes,
|
||||
AuthProof: &channeldb.ChannelAuthProof{
|
||||
AuthProof: &models.ChannelAuthProof{
|
||||
NodeSig1Bytes: testSig.Serialize(),
|
||||
NodeSig2Bytes: testSig.Serialize(),
|
||||
BitcoinSig1Bytes: testSig.Serialize(),
|
||||
@@ -469,7 +470,7 @@ func TestEdgeUpdateNotification(t *testing.T) {
|
||||
}
|
||||
|
||||
assertEdgeCorrect := func(t *testing.T, edgeUpdate *ChannelEdgeUpdate,
|
||||
edgeAnn *channeldb.ChannelEdgePolicy) {
|
||||
edgeAnn *models.ChannelEdgePolicy) {
|
||||
if edgeUpdate.ChanID != edgeAnn.ChannelID {
|
||||
t.Fatalf("channel ID of edge doesn't match: "+
|
||||
"expected %v, got %v", chanID.ToUint64(), edgeUpdate.ChanID)
|
||||
@@ -613,11 +614,11 @@ func TestNodeUpdateNotification(t *testing.T) {
|
||||
testFeaturesBuf := new(bytes.Buffer)
|
||||
require.NoError(t, testFeatures.Encode(testFeaturesBuf))
|
||||
|
||||
edge := &channeldb.ChannelEdgeInfo{
|
||||
edge := &models.ChannelEdgeInfo{
|
||||
ChannelID: chanID.ToUint64(),
|
||||
NodeKey1Bytes: node1.PubKeyBytes,
|
||||
NodeKey2Bytes: node2.PubKeyBytes,
|
||||
AuthProof: &channeldb.ChannelAuthProof{
|
||||
AuthProof: &models.ChannelAuthProof{
|
||||
NodeSig1Bytes: testSig.Serialize(),
|
||||
NodeSig2Bytes: testSig.Serialize(),
|
||||
BitcoinSig1Bytes: testSig.Serialize(),
|
||||
@@ -799,11 +800,11 @@ func TestNotificationCancellation(t *testing.T) {
|
||||
// to the client.
|
||||
ntfnClient.Cancel()
|
||||
|
||||
edge := &channeldb.ChannelEdgeInfo{
|
||||
edge := &models.ChannelEdgeInfo{
|
||||
ChannelID: chanID.ToUint64(),
|
||||
NodeKey1Bytes: node1.PubKeyBytes,
|
||||
NodeKey2Bytes: node2.PubKeyBytes,
|
||||
AuthProof: &channeldb.ChannelAuthProof{
|
||||
AuthProof: &models.ChannelAuthProof{
|
||||
NodeSig1Bytes: testSig.Serialize(),
|
||||
NodeSig2Bytes: testSig.Serialize(),
|
||||
BitcoinSig1Bytes: testSig.Serialize(),
|
||||
@@ -870,11 +871,11 @@ func TestChannelCloseNotification(t *testing.T) {
|
||||
|
||||
// Finally, to conclude our test set up, we'll create a channel
|
||||
// announcement to announce the created channel between the two nodes.
|
||||
edge := &channeldb.ChannelEdgeInfo{
|
||||
edge := &models.ChannelEdgeInfo{
|
||||
ChannelID: chanID.ToUint64(),
|
||||
NodeKey1Bytes: node1.PubKeyBytes,
|
||||
NodeKey2Bytes: node2.PubKeyBytes,
|
||||
AuthProof: &channeldb.ChannelAuthProof{
|
||||
AuthProof: &models.ChannelAuthProof{
|
||||
NodeSig1Bytes: testSig.Serialize(),
|
||||
NodeSig2Bytes: testSig.Serialize(),
|
||||
BitcoinSig1Bytes: testSig.Serialize(),
|
||||
|
||||
+7
-6
@@ -11,6 +11,7 @@ import (
|
||||
"github.com/btcsuite/btcd/btcutil"
|
||||
sphinx "github.com/lightningnetwork/lightning-onion"
|
||||
"github.com/lightningnetwork/lnd/channeldb"
|
||||
"github.com/lightningnetwork/lnd/channeldb/models"
|
||||
"github.com/lightningnetwork/lnd/feature"
|
||||
"github.com/lightningnetwork/lnd/lnwire"
|
||||
"github.com/lightningnetwork/lnd/record"
|
||||
@@ -49,7 +50,7 @@ const (
|
||||
type pathFinder = func(g *graphParams, r *RestrictParams,
|
||||
cfg *PathFindingConfig, source, target route.Vertex,
|
||||
amt lnwire.MilliSatoshi, timePref float64, finalHtlcExpiry int32) (
|
||||
[]*channeldb.CachedEdgePolicy, float64, error)
|
||||
[]*models.CachedEdgePolicy, float64, error)
|
||||
|
||||
var (
|
||||
// DefaultEstimator is the default estimator used for computing
|
||||
@@ -87,7 +88,7 @@ var (
|
||||
// of the edge.
|
||||
type edgePolicyWithSource struct {
|
||||
sourceNode route.Vertex
|
||||
edge *channeldb.CachedEdgePolicy
|
||||
edge *models.CachedEdgePolicy
|
||||
}
|
||||
|
||||
// finalHopParams encapsulates various parameters for route construction that
|
||||
@@ -125,7 +126,7 @@ type finalHopParams struct {
|
||||
// NOTE: If a non-nil blinded path is provided it is assumed to have been
|
||||
// validated by the caller.
|
||||
func newRoute(sourceVertex route.Vertex,
|
||||
pathEdges []*channeldb.CachedEdgePolicy, currentHeight uint32,
|
||||
pathEdges []*models.CachedEdgePolicy, currentHeight uint32,
|
||||
finalHop finalHopParams, blindedPath *sphinx.BlindedPath) (
|
||||
*route.Route, error) {
|
||||
|
||||
@@ -355,7 +356,7 @@ type graphParams struct {
|
||||
// additionalEdges is an optional set of edges that should be
|
||||
// considered during path finding, that is not already found in the
|
||||
// channel graph.
|
||||
additionalEdges map[route.Vertex][]*channeldb.CachedEdgePolicy
|
||||
additionalEdges map[route.Vertex][]*models.CachedEdgePolicy
|
||||
|
||||
// bandwidthHints is an interface that provides bandwidth hints that
|
||||
// can provide a better estimate of the current channel bandwidth than
|
||||
@@ -493,7 +494,7 @@ func getOutgoingBalance(node route.Vertex, outgoingChans map[uint64]struct{},
|
||||
// available bandwidth.
|
||||
func findPath(g *graphParams, r *RestrictParams, cfg *PathFindingConfig,
|
||||
source, target route.Vertex, amt lnwire.MilliSatoshi, timePref float64,
|
||||
finalHtlcExpiry int32) ([]*channeldb.CachedEdgePolicy, float64, error) {
|
||||
finalHtlcExpiry int32) ([]*models.CachedEdgePolicy, float64, error) {
|
||||
|
||||
// Pathfinding can be a significant portion of the total payment
|
||||
// latency, especially on low-powered devices. Log several metrics to
|
||||
@@ -994,7 +995,7 @@ func findPath(g *graphParams, r *RestrictParams, cfg *PathFindingConfig,
|
||||
|
||||
// Use the distance map to unravel the forward path from source to
|
||||
// target.
|
||||
var pathEdges []*channeldb.CachedEdgePolicy
|
||||
var pathEdges []*models.CachedEdgePolicy
|
||||
currentNode := source
|
||||
for {
|
||||
// Determine the next hop forward using the next map.
|
||||
|
||||
+31
-30
@@ -23,6 +23,7 @@ import (
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
sphinx "github.com/lightningnetwork/lightning-onion"
|
||||
"github.com/lightningnetwork/lnd/channeldb"
|
||||
"github.com/lightningnetwork/lnd/channeldb/models"
|
||||
"github.com/lightningnetwork/lnd/htlcswitch"
|
||||
"github.com/lightningnetwork/lnd/kvdb"
|
||||
"github.com/lightningnetwork/lnd/lnwire"
|
||||
@@ -96,7 +97,7 @@ var (
|
||||
_ = testSScalar.SetByteSlice(testSBytes)
|
||||
testSig = ecdsa.NewSignature(testRScalar, testSScalar)
|
||||
|
||||
testAuthProof = channeldb.ChannelAuthProof{
|
||||
testAuthProof = models.ChannelAuthProof{
|
||||
NodeSig1Bytes: testSig.Serialize(),
|
||||
NodeSig2Bytes: testSig.Serialize(),
|
||||
BitcoinSig1Bytes: testSig.Serialize(),
|
||||
@@ -335,7 +336,7 @@ func parseTestGraph(t *testing.T, useCache bool, path string) (
|
||||
|
||||
// We first insert the existence of the edge between the two
|
||||
// nodes.
|
||||
edgeInfo := channeldb.ChannelEdgeInfo{
|
||||
edgeInfo := models.ChannelEdgeInfo{
|
||||
ChannelID: edge.ChannelID,
|
||||
AuthProof: &testAuthProof,
|
||||
ChannelPoint: fundingPoint,
|
||||
@@ -366,7 +367,7 @@ func parseTestGraph(t *testing.T, useCache bool, path string) (
|
||||
targetNode = edgeInfo.NodeKey2Bytes
|
||||
}
|
||||
|
||||
edgePolicy := &channeldb.ChannelEdgePolicy{
|
||||
edgePolicy := &models.ChannelEdgePolicy{
|
||||
SigBytes: testSig.Serialize(),
|
||||
MessageFlags: lnwire.ChanUpdateMsgFlags(edge.MessageFlags),
|
||||
ChannelFlags: channelFlags,
|
||||
@@ -644,7 +645,7 @@ func createTestGraphFromChannels(t *testing.T, useCache bool,
|
||||
|
||||
// We first insert the existence of the edge between the two
|
||||
// nodes.
|
||||
edgeInfo := channeldb.ChannelEdgeInfo{
|
||||
edgeInfo := models.ChannelEdgeInfo{
|
||||
ChannelID: channelID,
|
||||
AuthProof: &testAuthProof,
|
||||
ChannelPoint: *fundingPoint,
|
||||
@@ -671,7 +672,7 @@ func createTestGraphFromChannels(t *testing.T, useCache bool,
|
||||
channelFlags |= lnwire.ChanUpdateDisabled
|
||||
}
|
||||
|
||||
edgePolicy := &channeldb.ChannelEdgePolicy{
|
||||
edgePolicy := &models.ChannelEdgePolicy{
|
||||
SigBytes: testSig.Serialize(),
|
||||
MessageFlags: msgFlags,
|
||||
ChannelFlags: channelFlags,
|
||||
@@ -700,7 +701,7 @@ func createTestGraphFromChannels(t *testing.T, useCache bool,
|
||||
}
|
||||
channelFlags |= lnwire.ChanUpdateDirection
|
||||
|
||||
edgePolicy := &channeldb.ChannelEdgePolicy{
|
||||
edgePolicy := &models.ChannelEdgePolicy{
|
||||
SigBytes: testSig.Serialize(),
|
||||
MessageFlags: msgFlags,
|
||||
ChannelFlags: channelFlags,
|
||||
@@ -1203,7 +1204,7 @@ func runPathFindingWithAdditionalEdges(t *testing.T, useCache bool) {
|
||||
|
||||
// Create the channel edge going from songoku to doge and include it in
|
||||
// our map of additional edges.
|
||||
songokuToDoge := &channeldb.CachedEdgePolicy{
|
||||
songokuToDoge := &models.CachedEdgePolicy{
|
||||
ToNodePubKey: func() route.Vertex {
|
||||
return doge.PubKeyBytes
|
||||
},
|
||||
@@ -1214,12 +1215,12 @@ func runPathFindingWithAdditionalEdges(t *testing.T, useCache bool) {
|
||||
TimeLockDelta: 9,
|
||||
}
|
||||
|
||||
additionalEdges := map[route.Vertex][]*channeldb.CachedEdgePolicy{
|
||||
additionalEdges := map[route.Vertex][]*models.CachedEdgePolicy{
|
||||
graph.aliasMap["songoku"]: {songokuToDoge},
|
||||
}
|
||||
|
||||
find := func(r *RestrictParams) (
|
||||
[]*channeldb.CachedEdgePolicy, error) {
|
||||
[]*models.CachedEdgePolicy, error) {
|
||||
|
||||
return dbFindPath(
|
||||
graph.graph, additionalEdges, &mockBandwidthHints{},
|
||||
@@ -1289,7 +1290,7 @@ func runPathFindingWithRedundantAdditionalEdges(t *testing.T, useCache bool) {
|
||||
|
||||
// Create the channel edge going from alice to bob and include it in
|
||||
// our map of additional edges.
|
||||
aliceToBob := &channeldb.CachedEdgePolicy{
|
||||
aliceToBob := &models.CachedEdgePolicy{
|
||||
ToNodePubKey: func() route.Vertex {
|
||||
return target
|
||||
},
|
||||
@@ -1300,7 +1301,7 @@ func runPathFindingWithRedundantAdditionalEdges(t *testing.T, useCache bool) {
|
||||
TimeLockDelta: 9,
|
||||
}
|
||||
|
||||
additionalEdges := map[route.Vertex][]*channeldb.CachedEdgePolicy{
|
||||
additionalEdges := map[route.Vertex][]*models.CachedEdgePolicy{
|
||||
ctx.source: {aliceToBob},
|
||||
}
|
||||
|
||||
@@ -1334,9 +1335,9 @@ func TestNewRoute(t *testing.T) {
|
||||
createHop := func(baseFee lnwire.MilliSatoshi,
|
||||
feeRate lnwire.MilliSatoshi,
|
||||
bandwidth lnwire.MilliSatoshi,
|
||||
timeLockDelta uint16) *channeldb.CachedEdgePolicy {
|
||||
timeLockDelta uint16) *models.CachedEdgePolicy {
|
||||
|
||||
return &channeldb.CachedEdgePolicy{
|
||||
return &models.CachedEdgePolicy{
|
||||
ToNodePubKey: func() route.Vertex {
|
||||
return route.Vertex{}
|
||||
},
|
||||
@@ -1353,7 +1354,7 @@ func TestNewRoute(t *testing.T) {
|
||||
|
||||
// hops is the list of hops (the route) that gets passed into
|
||||
// the call to newRoute.
|
||||
hops []*channeldb.CachedEdgePolicy
|
||||
hops []*models.CachedEdgePolicy
|
||||
|
||||
// paymentAmount is the amount that is send into the route
|
||||
// indicated by hops.
|
||||
@@ -1405,7 +1406,7 @@ func TestNewRoute(t *testing.T) {
|
||||
// For a single hop payment, no fees are expected to be paid.
|
||||
name: "single hop",
|
||||
paymentAmount: 100000,
|
||||
hops: []*channeldb.CachedEdgePolicy{
|
||||
hops: []*models.CachedEdgePolicy{
|
||||
createHop(100, 1000, 1000000, 10),
|
||||
},
|
||||
metadata: []byte{1, 2, 3},
|
||||
@@ -1419,7 +1420,7 @@ func TestNewRoute(t *testing.T) {
|
||||
// a fee to receive the payment.
|
||||
name: "two hop",
|
||||
paymentAmount: 100000,
|
||||
hops: []*channeldb.CachedEdgePolicy{
|
||||
hops: []*models.CachedEdgePolicy{
|
||||
createHop(0, 1000, 1000000, 10),
|
||||
createHop(30, 1000, 1000000, 5),
|
||||
},
|
||||
@@ -1434,7 +1435,7 @@ func TestNewRoute(t *testing.T) {
|
||||
name: "two hop tlv onion feature",
|
||||
destFeatures: tlvFeatures,
|
||||
paymentAmount: 100000,
|
||||
hops: []*channeldb.CachedEdgePolicy{
|
||||
hops: []*models.CachedEdgePolicy{
|
||||
createHop(0, 1000, 1000000, 10),
|
||||
createHop(30, 1000, 1000000, 5),
|
||||
},
|
||||
@@ -1451,7 +1452,7 @@ func TestNewRoute(t *testing.T) {
|
||||
destFeatures: tlvPayAddrFeatures,
|
||||
paymentAddr: &testPaymentAddr,
|
||||
paymentAmount: 100000,
|
||||
hops: []*channeldb.CachedEdgePolicy{
|
||||
hops: []*models.CachedEdgePolicy{
|
||||
createHop(0, 1000, 1000000, 10),
|
||||
createHop(30, 1000, 1000000, 5),
|
||||
},
|
||||
@@ -1471,7 +1472,7 @@ func TestNewRoute(t *testing.T) {
|
||||
// gets rounded down to 1.
|
||||
name: "three hop",
|
||||
paymentAmount: 100000,
|
||||
hops: []*channeldb.CachedEdgePolicy{
|
||||
hops: []*models.CachedEdgePolicy{
|
||||
createHop(0, 10, 1000000, 10),
|
||||
createHop(0, 10, 1000000, 5),
|
||||
createHop(0, 10, 1000000, 3),
|
||||
@@ -1486,7 +1487,7 @@ func TestNewRoute(t *testing.T) {
|
||||
// because of the increase amount to forward.
|
||||
name: "three hop with fee carry over",
|
||||
paymentAmount: 100000,
|
||||
hops: []*channeldb.CachedEdgePolicy{
|
||||
hops: []*models.CachedEdgePolicy{
|
||||
createHop(0, 10000, 1000000, 10),
|
||||
createHop(0, 10000, 1000000, 5),
|
||||
createHop(0, 10000, 1000000, 3),
|
||||
@@ -1501,7 +1502,7 @@ func TestNewRoute(t *testing.T) {
|
||||
// effect.
|
||||
name: "three hop with minimal fees for carry over",
|
||||
paymentAmount: 100000,
|
||||
hops: []*channeldb.CachedEdgePolicy{
|
||||
hops: []*models.CachedEdgePolicy{
|
||||
createHop(0, 10000, 1000000, 10),
|
||||
|
||||
// First hop charges 0.1% so the second hop fee
|
||||
@@ -1740,7 +1741,7 @@ func runDestTLVGraphFallback(t *testing.T, useCache bool) {
|
||||
require.NoError(t, err, "unable to fetch source node")
|
||||
|
||||
find := func(r *RestrictParams,
|
||||
target route.Vertex) ([]*channeldb.CachedEdgePolicy, error) {
|
||||
target route.Vertex) ([]*models.CachedEdgePolicy, error) {
|
||||
|
||||
return dbFindPath(
|
||||
ctx.graph, nil, &mockBandwidthHints{},
|
||||
@@ -2398,7 +2399,7 @@ func TestPathFindSpecExample(t *testing.T) {
|
||||
}
|
||||
|
||||
func assertExpectedPath(t *testing.T, aliasMap map[string]route.Vertex,
|
||||
path []*channeldb.CachedEdgePolicy, nodeAliases ...string) {
|
||||
path []*models.CachedEdgePolicy, nodeAliases ...string) {
|
||||
|
||||
if len(path) != len(nodeAliases) {
|
||||
t.Fatal("number of hops and number of aliases do not match")
|
||||
@@ -3043,7 +3044,7 @@ func (c *pathFindingTestContext) aliasFromKey(pubKey route.Vertex) string {
|
||||
}
|
||||
|
||||
func (c *pathFindingTestContext) findPath(target route.Vertex,
|
||||
amt lnwire.MilliSatoshi) ([]*channeldb.CachedEdgePolicy,
|
||||
amt lnwire.MilliSatoshi) ([]*models.CachedEdgePolicy,
|
||||
error) {
|
||||
|
||||
return dbFindPath(
|
||||
@@ -3052,7 +3053,7 @@ func (c *pathFindingTestContext) findPath(target route.Vertex,
|
||||
)
|
||||
}
|
||||
|
||||
func (c *pathFindingTestContext) assertPath(path []*channeldb.CachedEdgePolicy,
|
||||
func (c *pathFindingTestContext) assertPath(path []*models.CachedEdgePolicy,
|
||||
expected []uint64) {
|
||||
|
||||
if len(path) != len(expected) {
|
||||
@@ -3071,11 +3072,11 @@ func (c *pathFindingTestContext) assertPath(path []*channeldb.CachedEdgePolicy,
|
||||
// dbFindPath calls findPath after getting a db transaction from the database
|
||||
// graph.
|
||||
func dbFindPath(graph *channeldb.ChannelGraph,
|
||||
additionalEdges map[route.Vertex][]*channeldb.CachedEdgePolicy,
|
||||
additionalEdges map[route.Vertex][]*models.CachedEdgePolicy,
|
||||
bandwidthHints bandwidthHints,
|
||||
r *RestrictParams, cfg *PathFindingConfig,
|
||||
source, target route.Vertex, amt lnwire.MilliSatoshi, timePref float64,
|
||||
finalHtlcExpiry int32) ([]*channeldb.CachedEdgePolicy, error) {
|
||||
finalHtlcExpiry int32) ([]*models.CachedEdgePolicy, error) {
|
||||
|
||||
sourceNode, err := graph.SourceNode()
|
||||
if err != nil {
|
||||
@@ -3179,7 +3180,7 @@ func TestBlindedRouteConstruction(t *testing.T) {
|
||||
// route. Proportional fees are omitted for easy test
|
||||
// calculations, but non-zero base fees ensure our fee is
|
||||
// still accounted for.
|
||||
aliceBobEdge = &channeldb.CachedEdgePolicy{
|
||||
aliceBobEdge = &models.CachedEdgePolicy{
|
||||
ChannelID: 1,
|
||||
// We won't actually use this timelock / fee (since
|
||||
// it's the sender's outbound channel), but we include
|
||||
@@ -3193,7 +3194,7 @@ func TestBlindedRouteConstruction(t *testing.T) {
|
||||
ToNodeFeatures: tlvFeatures,
|
||||
}
|
||||
|
||||
bobCarolEdge = &channeldb.CachedEdgePolicy{
|
||||
bobCarolEdge = &models.CachedEdgePolicy{
|
||||
ChannelID: 2,
|
||||
TimeLockDelta: 15,
|
||||
FeeBaseMSat: 20,
|
||||
@@ -3226,7 +3227,7 @@ func TestBlindedRouteConstruction(t *testing.T) {
|
||||
carolDaveEdge := blindedEdges[carolVertex][0]
|
||||
daveEveEdge := blindedEdges[daveBlindedVertex][0]
|
||||
|
||||
edges := []*channeldb.CachedEdgePolicy{
|
||||
edges := []*models.CachedEdgePolicy{
|
||||
aliceBobEdge,
|
||||
bobCarolEdge,
|
||||
carolDaveEdge,
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
"github.com/go-errors/errors"
|
||||
sphinx "github.com/lightningnetwork/lightning-onion"
|
||||
"github.com/lightningnetwork/lnd/channeldb"
|
||||
"github.com/lightningnetwork/lnd/channeldb/models"
|
||||
"github.com/lightningnetwork/lnd/htlcswitch"
|
||||
"github.com/lightningnetwork/lnd/lntypes"
|
||||
"github.com/lightningnetwork/lnd/lnwire"
|
||||
@@ -874,7 +875,7 @@ func (p *shardHandler) handleFailureMessage(rt *route.Route,
|
||||
|
||||
var (
|
||||
isAdditionalEdge bool
|
||||
policy *channeldb.CachedEdgePolicy
|
||||
policy *models.CachedEdgePolicy
|
||||
)
|
||||
|
||||
// Before we apply the channel update, we need to decide whether the
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"github.com/davecgh/go-spew/spew"
|
||||
"github.com/lightningnetwork/lnd/build"
|
||||
"github.com/lightningnetwork/lnd/channeldb"
|
||||
"github.com/lightningnetwork/lnd/channeldb/models"
|
||||
"github.com/lightningnetwork/lnd/lnwire"
|
||||
"github.com/lightningnetwork/lnd/routing/route"
|
||||
)
|
||||
@@ -144,13 +145,13 @@ type PaymentSession interface {
|
||||
// a boolean to indicate whether the update has been applied without
|
||||
// error.
|
||||
UpdateAdditionalEdge(msg *lnwire.ChannelUpdate, pubKey *btcec.PublicKey,
|
||||
policy *channeldb.CachedEdgePolicy) bool
|
||||
policy *models.CachedEdgePolicy) bool
|
||||
|
||||
// GetAdditionalEdgePolicy uses the public key and channel ID to query
|
||||
// the ephemeral channel edge policy for additional edges. Returns a nil
|
||||
// if nothing found.
|
||||
GetAdditionalEdgePolicy(pubKey *btcec.PublicKey,
|
||||
channelID uint64) *channeldb.CachedEdgePolicy
|
||||
channelID uint64) *models.CachedEdgePolicy
|
||||
}
|
||||
|
||||
// paymentSession is used during an HTLC routings session to prune the local
|
||||
@@ -162,7 +163,7 @@ type PaymentSession interface {
|
||||
// loop if payment attempts take long enough. An additional set of edges can
|
||||
// also be provided to assist in reaching the payment's destination.
|
||||
type paymentSession struct {
|
||||
additionalEdges map[route.Vertex][]*channeldb.CachedEdgePolicy
|
||||
additionalEdges map[route.Vertex][]*models.CachedEdgePolicy
|
||||
|
||||
getBandwidthHints func(routingGraph) (bandwidthHints, error)
|
||||
|
||||
@@ -405,7 +406,7 @@ func (p *paymentSession) RequestRoute(maxAmt, feeLimit lnwire.MilliSatoshi,
|
||||
// updates to the supplied policy. It returns a boolean to indicate whether
|
||||
// there's an error when applying the updates.
|
||||
func (p *paymentSession) UpdateAdditionalEdge(msg *lnwire.ChannelUpdate,
|
||||
pubKey *btcec.PublicKey, policy *channeldb.CachedEdgePolicy) bool {
|
||||
pubKey *btcec.PublicKey, policy *models.CachedEdgePolicy) bool {
|
||||
|
||||
// Validate the message signature.
|
||||
if err := VerifyChannelUpdateSignature(msg, pubKey); err != nil {
|
||||
@@ -430,7 +431,7 @@ func (p *paymentSession) UpdateAdditionalEdge(msg *lnwire.ChannelUpdate,
|
||||
// ephemeral channel edge policy for additional edges. Returns a nil if nothing
|
||||
// found.
|
||||
func (p *paymentSession) GetAdditionalEdgePolicy(pubKey *btcec.PublicKey,
|
||||
channelID uint64) *channeldb.CachedEdgePolicy {
|
||||
channelID uint64) *models.CachedEdgePolicy {
|
||||
|
||||
target := route.NewVertex(pubKey)
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ package routing
|
||||
import (
|
||||
"github.com/btcsuite/btcd/btcec/v2"
|
||||
"github.com/lightningnetwork/lnd/channeldb"
|
||||
"github.com/lightningnetwork/lnd/channeldb/models"
|
||||
"github.com/lightningnetwork/lnd/lnwire"
|
||||
"github.com/lightningnetwork/lnd/routing/route"
|
||||
"github.com/lightningnetwork/lnd/zpay32"
|
||||
@@ -94,9 +95,9 @@ func (m *SessionSource) NewPaymentSessionEmpty() PaymentSession {
|
||||
// RouteHintsToEdges converts a list of invoice route hints to an edge map that
|
||||
// can be passed into pathfinding.
|
||||
func RouteHintsToEdges(routeHints [][]zpay32.HopHint, target route.Vertex) (
|
||||
map[route.Vertex][]*channeldb.CachedEdgePolicy, error) {
|
||||
map[route.Vertex][]*models.CachedEdgePolicy, error) {
|
||||
|
||||
edges := make(map[route.Vertex][]*channeldb.CachedEdgePolicy)
|
||||
edges := make(map[route.Vertex][]*models.CachedEdgePolicy)
|
||||
|
||||
// Traverse through all of the available hop hints and include them in
|
||||
// our edges map, indexed by the public key of the channel's starting
|
||||
@@ -126,7 +127,7 @@ func RouteHintsToEdges(routeHints [][]zpay32.HopHint, target route.Vertex) (
|
||||
// Finally, create the channel edge from the hop hint
|
||||
// and add it to list of edges corresponding to the node
|
||||
// at the start of the channel.
|
||||
edge := &channeldb.CachedEdgePolicy{
|
||||
edge := &models.CachedEdgePolicy{
|
||||
ToNodePubKey: func() route.Vertex {
|
||||
return endNode.PubKeyBytes
|
||||
},
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/lightningnetwork/lnd/channeldb"
|
||||
"github.com/lightningnetwork/lnd/channeldb/models"
|
||||
"github.com/lightningnetwork/lnd/lntypes"
|
||||
"github.com/lightningnetwork/lnd/lnwire"
|
||||
"github.com/lightningnetwork/lnd/routing/route"
|
||||
@@ -211,7 +212,7 @@ func TestRequestRoute(t *testing.T) {
|
||||
// Override pathfinder with a mock.
|
||||
session.pathFinder = func(_ *graphParams, r *RestrictParams,
|
||||
_ *PathFindingConfig, _, _ route.Vertex, _ lnwire.MilliSatoshi,
|
||||
_ float64, _ int32) ([]*channeldb.CachedEdgePolicy, float64,
|
||||
_ float64, _ int32) ([]*models.CachedEdgePolicy, float64,
|
||||
error) {
|
||||
|
||||
// We expect find path to receive a cltv limit excluding the
|
||||
@@ -220,7 +221,7 @@ func TestRequestRoute(t *testing.T) {
|
||||
t.Fatal("wrong cltv limit")
|
||||
}
|
||||
|
||||
path := []*channeldb.CachedEdgePolicy{
|
||||
path := []*models.CachedEdgePolicy{
|
||||
{
|
||||
ToNodePubKey: func() route.Vertex {
|
||||
return route.Vertex{}
|
||||
|
||||
+27
-26
@@ -21,6 +21,7 @@ import (
|
||||
"github.com/lightningnetwork/lnd/batch"
|
||||
"github.com/lightningnetwork/lnd/chainntnfs"
|
||||
"github.com/lightningnetwork/lnd/channeldb"
|
||||
"github.com/lightningnetwork/lnd/channeldb/models"
|
||||
"github.com/lightningnetwork/lnd/clock"
|
||||
"github.com/lightningnetwork/lnd/htlcswitch"
|
||||
"github.com/lightningnetwork/lnd/input"
|
||||
@@ -135,17 +136,17 @@ type ChannelGraphSource interface {
|
||||
// AddEdge is used to add edge/channel to the topology of the router,
|
||||
// after all information about channel will be gathered this
|
||||
// edge/channel might be used in construction of payment path.
|
||||
AddEdge(edge *channeldb.ChannelEdgeInfo,
|
||||
AddEdge(edge *models.ChannelEdgeInfo,
|
||||
op ...batch.SchedulerOption) error
|
||||
|
||||
// AddProof updates the channel edge info with proof which is needed to
|
||||
// properly announce the edge to the rest of the network.
|
||||
AddProof(chanID lnwire.ShortChannelID,
|
||||
proof *channeldb.ChannelAuthProof) error
|
||||
proof *models.ChannelAuthProof) error
|
||||
|
||||
// UpdateEdge is used to update edge information, without this message
|
||||
// edge considered as not fully constructed.
|
||||
UpdateEdge(policy *channeldb.ChannelEdgePolicy,
|
||||
UpdateEdge(policy *models.ChannelEdgePolicy,
|
||||
op ...batch.SchedulerOption) error
|
||||
|
||||
// IsStaleNode returns true if the graph source has a node announcement
|
||||
@@ -176,8 +177,8 @@ type ChannelGraphSource interface {
|
||||
// emanating from the "source" node which is the center of the
|
||||
// star-graph.
|
||||
ForAllOutgoingChannels(cb func(tx kvdb.RTx,
|
||||
c *channeldb.ChannelEdgeInfo,
|
||||
e *channeldb.ChannelEdgePolicy) error) error
|
||||
c *models.ChannelEdgeInfo,
|
||||
e *models.ChannelEdgePolicy) error) error
|
||||
|
||||
// CurrentBlockHeight returns the block height from POV of the router
|
||||
// subsystem.
|
||||
@@ -185,8 +186,8 @@ type ChannelGraphSource interface {
|
||||
|
||||
// GetChannelByID return the channel by the channel id.
|
||||
GetChannelByID(chanID lnwire.ShortChannelID) (
|
||||
*channeldb.ChannelEdgeInfo, *channeldb.ChannelEdgePolicy,
|
||||
*channeldb.ChannelEdgePolicy, error)
|
||||
*models.ChannelEdgeInfo, *models.ChannelEdgePolicy,
|
||||
*models.ChannelEdgePolicy, error)
|
||||
|
||||
// FetchLightningNode attempts to look up a target node by its identity
|
||||
// public key. channeldb.ErrGraphNodeNotFound is returned if the node
|
||||
@@ -897,15 +898,15 @@ func (r *ChannelRouter) pruneZombieChans() error {
|
||||
log.Infof("Examining channel graph for zombie channels")
|
||||
|
||||
// A helper method to detect if the channel belongs to this node
|
||||
isSelfChannelEdge := func(info *channeldb.ChannelEdgeInfo) bool {
|
||||
isSelfChannelEdge := func(info *models.ChannelEdgeInfo) bool {
|
||||
return info.NodeKey1Bytes == r.selfNode.PubKeyBytes ||
|
||||
info.NodeKey2Bytes == r.selfNode.PubKeyBytes
|
||||
}
|
||||
|
||||
// First, we'll collect all the channels which are eligible for garbage
|
||||
// collection due to being zombies.
|
||||
filterPruneChans := func(info *channeldb.ChannelEdgeInfo,
|
||||
e1, e2 *channeldb.ChannelEdgePolicy) error {
|
||||
filterPruneChans := func(info *models.ChannelEdgeInfo,
|
||||
e1, e2 *models.ChannelEdgePolicy) error {
|
||||
|
||||
// Exit early in case this channel is already marked to be pruned
|
||||
if _, markedToPrune := chansToPrune[info.ChannelID]; markedToPrune {
|
||||
@@ -1539,7 +1540,7 @@ func (r *ChannelRouter) processUpdate(msg interface{},
|
||||
log.Tracef("Updated vertex data for node=%x", msg.PubKeyBytes)
|
||||
r.stats.incNumNodeUpdates()
|
||||
|
||||
case *channeldb.ChannelEdgeInfo:
|
||||
case *models.ChannelEdgeInfo:
|
||||
log.Debugf("Received ChannelEdgeInfo for channel %v",
|
||||
msg.ChannelID)
|
||||
|
||||
@@ -1706,7 +1707,7 @@ func (r *ChannelRouter) processUpdate(msg interface{},
|
||||
"view: %v", err)
|
||||
}
|
||||
|
||||
case *channeldb.ChannelEdgePolicy:
|
||||
case *models.ChannelEdgePolicy:
|
||||
log.Debugf("Received ChannelEdgePolicy for channel %v",
|
||||
msg.ChannelID)
|
||||
|
||||
@@ -1883,7 +1884,7 @@ type RouteRequest struct {
|
||||
|
||||
// RouteHints is an alias type for a set of route hints, with the source node
|
||||
// as the map's key and the details of the hint(s) in the edge policy.
|
||||
type RouteHints map[route.Vertex][]*channeldb.CachedEdgePolicy
|
||||
type RouteHints map[route.Vertex][]*models.CachedEdgePolicy
|
||||
|
||||
// NewRouteRequest produces a new route request for a regular payment or one
|
||||
// to a blinded route, validating that the target, routeHints and finalExpiry
|
||||
@@ -2668,7 +2669,7 @@ func (r *ChannelRouter) applyChannelUpdate(msg *lnwire.ChannelUpdate) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
err = r.UpdateEdge(&channeldb.ChannelEdgePolicy{
|
||||
err = r.UpdateEdge(&models.ChannelEdgePolicy{
|
||||
SigBytes: msg.Signature.ToSignatureBytes(),
|
||||
ChannelID: msg.ShortChannelID.ToUint64(),
|
||||
LastUpdate: time.Unix(int64(msg.Timestamp), 0),
|
||||
@@ -2720,7 +2721,7 @@ func (r *ChannelRouter) AddNode(node *channeldb.LightningNode,
|
||||
// in construction of payment path.
|
||||
//
|
||||
// NOTE: This method is part of the ChannelGraphSource interface.
|
||||
func (r *ChannelRouter) AddEdge(edge *channeldb.ChannelEdgeInfo,
|
||||
func (r *ChannelRouter) AddEdge(edge *models.ChannelEdgeInfo,
|
||||
op ...batch.SchedulerOption) error {
|
||||
|
||||
rMsg := &routingMsg{
|
||||
@@ -2746,7 +2747,7 @@ func (r *ChannelRouter) AddEdge(edge *channeldb.ChannelEdgeInfo,
|
||||
// considered as not fully constructed.
|
||||
//
|
||||
// NOTE: This method is part of the ChannelGraphSource interface.
|
||||
func (r *ChannelRouter) UpdateEdge(update *channeldb.ChannelEdgePolicy,
|
||||
func (r *ChannelRouter) UpdateEdge(update *models.ChannelEdgePolicy,
|
||||
op ...batch.SchedulerOption) error {
|
||||
|
||||
rMsg := &routingMsg{
|
||||
@@ -2787,9 +2788,9 @@ func (r *ChannelRouter) SyncedHeight() uint32 {
|
||||
//
|
||||
// NOTE: This method is part of the ChannelGraphSource interface.
|
||||
func (r *ChannelRouter) GetChannelByID(chanID lnwire.ShortChannelID) (
|
||||
*channeldb.ChannelEdgeInfo,
|
||||
*channeldb.ChannelEdgePolicy,
|
||||
*channeldb.ChannelEdgePolicy, error) {
|
||||
*models.ChannelEdgeInfo,
|
||||
*models.ChannelEdgePolicy,
|
||||
*models.ChannelEdgePolicy, error) {
|
||||
|
||||
return r.cfg.Graph.FetchChannelEdgesByID(chanID.ToUint64())
|
||||
}
|
||||
@@ -2822,12 +2823,12 @@ func (r *ChannelRouter) ForEachNode(
|
||||
//
|
||||
// NOTE: This method is part of the ChannelGraphSource interface.
|
||||
func (r *ChannelRouter) ForAllOutgoingChannels(cb func(kvdb.RTx,
|
||||
*channeldb.ChannelEdgeInfo, *channeldb.ChannelEdgePolicy) error) error {
|
||||
*models.ChannelEdgeInfo, *models.ChannelEdgePolicy) error) error {
|
||||
|
||||
return r.cfg.Graph.ForEachNodeChannel(nil, r.selfNode.PubKeyBytes,
|
||||
func(tx kvdb.RTx, c *channeldb.ChannelEdgeInfo,
|
||||
e *channeldb.ChannelEdgePolicy,
|
||||
_ *channeldb.ChannelEdgePolicy) error {
|
||||
func(tx kvdb.RTx, c *models.ChannelEdgeInfo,
|
||||
e *models.ChannelEdgePolicy,
|
||||
_ *models.ChannelEdgePolicy) error {
|
||||
|
||||
if e == nil {
|
||||
return fmt.Errorf("channel from self node " +
|
||||
@@ -2844,7 +2845,7 @@ func (r *ChannelRouter) ForAllOutgoingChannels(cb func(kvdb.RTx,
|
||||
//
|
||||
// NOTE: This method is part of the ChannelGraphSource interface.
|
||||
func (r *ChannelRouter) AddProof(chanID lnwire.ShortChannelID,
|
||||
proof *channeldb.ChannelAuthProof) error {
|
||||
proof *models.ChannelAuthProof) error {
|
||||
|
||||
info, _, _, err := r.cfg.Graph.FetchChannelEdgesByID(chanID.ToUint64())
|
||||
if err != nil {
|
||||
@@ -3129,14 +3130,14 @@ func getRouteUnifiers(source route.Vertex, hops []route.Vertex,
|
||||
// including fees, to send the payment.
|
||||
func getPathEdges(source route.Vertex, receiverAmt lnwire.MilliSatoshi,
|
||||
unifiers []*edgeUnifier, bandwidthHints *bandwidthManager,
|
||||
hops []route.Vertex) ([]*channeldb.CachedEdgePolicy,
|
||||
hops []route.Vertex) ([]*models.CachedEdgePolicy,
|
||||
lnwire.MilliSatoshi, error) {
|
||||
|
||||
// Now that we arrived at the start of the route and found out the route
|
||||
// total amount, we make a forward pass. Because the amount may have
|
||||
// been increased in the backward pass, fees need to be recalculated and
|
||||
// amount ranges re-checked.
|
||||
var pathEdges []*channeldb.CachedEdgePolicy
|
||||
var pathEdges []*models.CachedEdgePolicy
|
||||
for i, unifier := range unifiers {
|
||||
edge := unifier.getEdge(receiverAmt, bandwidthHints)
|
||||
if edge == nil {
|
||||
|
||||
+30
-29
@@ -19,6 +19,7 @@ import (
|
||||
sphinx "github.com/lightningnetwork/lightning-onion"
|
||||
"github.com/lightningnetwork/lnd/chainntnfs"
|
||||
"github.com/lightningnetwork/lnd/channeldb"
|
||||
"github.com/lightningnetwork/lnd/channeldb/models"
|
||||
"github.com/lightningnetwork/lnd/clock"
|
||||
"github.com/lightningnetwork/lnd/htlcswitch"
|
||||
lnmock "github.com/lightningnetwork/lnd/lntest/mock"
|
||||
@@ -1241,7 +1242,7 @@ func TestAddProof(t *testing.T) {
|
||||
ctx.chain.addBlock(fundingBlock, chanID.BlockHeight, chanID.BlockHeight)
|
||||
|
||||
// After utxo was recreated adding the edge without the proof.
|
||||
edge := &channeldb.ChannelEdgeInfo{
|
||||
edge := &models.ChannelEdgeInfo{
|
||||
ChannelID: chanID.ToUint64(),
|
||||
NodeKey1Bytes: node1.PubKeyBytes,
|
||||
NodeKey2Bytes: node2.PubKeyBytes,
|
||||
@@ -1330,7 +1331,7 @@ func TestIgnoreChannelEdgePolicyForUnknownChannel(t *testing.T) {
|
||||
}
|
||||
ctx.chain.addBlock(fundingBlock, chanID.BlockHeight, chanID.BlockHeight)
|
||||
|
||||
edge := &channeldb.ChannelEdgeInfo{
|
||||
edge := &models.ChannelEdgeInfo{
|
||||
ChannelID: chanID.ToUint64(),
|
||||
NodeKey1Bytes: pub1,
|
||||
NodeKey2Bytes: pub2,
|
||||
@@ -1338,7 +1339,7 @@ func TestIgnoreChannelEdgePolicyForUnknownChannel(t *testing.T) {
|
||||
BitcoinKey2Bytes: pub2,
|
||||
AuthProof: nil,
|
||||
}
|
||||
edgePolicy := &channeldb.ChannelEdgePolicy{
|
||||
edgePolicy := &models.ChannelEdgePolicy{
|
||||
SigBytes: testSig.Serialize(),
|
||||
ChannelID: edge.ChannelID,
|
||||
LastUpdate: testTime,
|
||||
@@ -1408,7 +1409,7 @@ func TestAddEdgeUnknownVertexes(t *testing.T) {
|
||||
}
|
||||
ctx.chain.addBlock(fundingBlock, chanID.BlockHeight, chanID.BlockHeight)
|
||||
|
||||
edge := &channeldb.ChannelEdgeInfo{
|
||||
edge := &models.ChannelEdgeInfo{
|
||||
ChannelID: chanID.ToUint64(),
|
||||
NodeKey1Bytes: pub1,
|
||||
NodeKey2Bytes: pub2,
|
||||
@@ -1423,7 +1424,7 @@ func TestAddEdgeUnknownVertexes(t *testing.T) {
|
||||
|
||||
// We must add the edge policy to be able to use the edge for route
|
||||
// finding.
|
||||
edgePolicy := &channeldb.ChannelEdgePolicy{
|
||||
edgePolicy := &models.ChannelEdgePolicy{
|
||||
SigBytes: testSig.Serialize(),
|
||||
ChannelID: edge.ChannelID,
|
||||
LastUpdate: testTime,
|
||||
@@ -1440,7 +1441,7 @@ func TestAddEdgeUnknownVertexes(t *testing.T) {
|
||||
}
|
||||
|
||||
// Create edge in the other direction as well.
|
||||
edgePolicy = &channeldb.ChannelEdgePolicy{
|
||||
edgePolicy = &models.ChannelEdgePolicy{
|
||||
SigBytes: testSig.Serialize(),
|
||||
ChannelID: edge.ChannelID,
|
||||
LastUpdate: testTime,
|
||||
@@ -1503,7 +1504,7 @@ func TestAddEdgeUnknownVertexes(t *testing.T) {
|
||||
}
|
||||
ctx.chain.addBlock(fundingBlock, chanID.BlockHeight, chanID.BlockHeight)
|
||||
|
||||
edge = &channeldb.ChannelEdgeInfo{
|
||||
edge = &models.ChannelEdgeInfo{
|
||||
ChannelID: chanID.ToUint64(),
|
||||
AuthProof: nil,
|
||||
}
|
||||
@@ -1516,7 +1517,7 @@ func TestAddEdgeUnknownVertexes(t *testing.T) {
|
||||
t.Fatalf("unable to add edge to the channel graph: %v.", err)
|
||||
}
|
||||
|
||||
edgePolicy = &channeldb.ChannelEdgePolicy{
|
||||
edgePolicy = &models.ChannelEdgePolicy{
|
||||
SigBytes: testSig.Serialize(),
|
||||
ChannelID: edge.ChannelID,
|
||||
LastUpdate: testTime,
|
||||
@@ -1532,7 +1533,7 @@ func TestAddEdgeUnknownVertexes(t *testing.T) {
|
||||
t.Fatalf("unable to update edge policy: %v", err)
|
||||
}
|
||||
|
||||
edgePolicy = &channeldb.ChannelEdgePolicy{
|
||||
edgePolicy = &models.ChannelEdgePolicy{
|
||||
SigBytes: testSig.Serialize(),
|
||||
ChannelID: edge.ChannelID,
|
||||
LastUpdate: testTime,
|
||||
@@ -1702,11 +1703,11 @@ func TestWakeUpOnStaleBranch(t *testing.T) {
|
||||
node2, err := createTestNode()
|
||||
require.NoError(t, err, "unable to create test node")
|
||||
|
||||
edge1 := &channeldb.ChannelEdgeInfo{
|
||||
edge1 := &models.ChannelEdgeInfo{
|
||||
ChannelID: chanID1,
|
||||
NodeKey1Bytes: node1.PubKeyBytes,
|
||||
NodeKey2Bytes: node2.PubKeyBytes,
|
||||
AuthProof: &channeldb.ChannelAuthProof{
|
||||
AuthProof: &models.ChannelAuthProof{
|
||||
NodeSig1Bytes: testSig.Serialize(),
|
||||
NodeSig2Bytes: testSig.Serialize(),
|
||||
BitcoinSig1Bytes: testSig.Serialize(),
|
||||
@@ -1720,11 +1721,11 @@ func TestWakeUpOnStaleBranch(t *testing.T) {
|
||||
t.Fatalf("unable to add edge: %v", err)
|
||||
}
|
||||
|
||||
edge2 := &channeldb.ChannelEdgeInfo{
|
||||
edge2 := &models.ChannelEdgeInfo{
|
||||
ChannelID: chanID2,
|
||||
NodeKey1Bytes: node1.PubKeyBytes,
|
||||
NodeKey2Bytes: node2.PubKeyBytes,
|
||||
AuthProof: &channeldb.ChannelAuthProof{
|
||||
AuthProof: &models.ChannelAuthProof{
|
||||
NodeSig1Bytes: testSig.Serialize(),
|
||||
NodeSig2Bytes: testSig.Serialize(),
|
||||
BitcoinSig1Bytes: testSig.Serialize(),
|
||||
@@ -1910,13 +1911,13 @@ func TestDisconnectedBlocks(t *testing.T) {
|
||||
node2, err := createTestNode()
|
||||
require.NoError(t, err, "unable to create test node")
|
||||
|
||||
edge1 := &channeldb.ChannelEdgeInfo{
|
||||
edge1 := &models.ChannelEdgeInfo{
|
||||
ChannelID: chanID1,
|
||||
NodeKey1Bytes: node1.PubKeyBytes,
|
||||
NodeKey2Bytes: node2.PubKeyBytes,
|
||||
BitcoinKey1Bytes: node1.PubKeyBytes,
|
||||
BitcoinKey2Bytes: node2.PubKeyBytes,
|
||||
AuthProof: &channeldb.ChannelAuthProof{
|
||||
AuthProof: &models.ChannelAuthProof{
|
||||
NodeSig1Bytes: testSig.Serialize(),
|
||||
NodeSig2Bytes: testSig.Serialize(),
|
||||
BitcoinSig1Bytes: testSig.Serialize(),
|
||||
@@ -1930,13 +1931,13 @@ func TestDisconnectedBlocks(t *testing.T) {
|
||||
t.Fatalf("unable to add edge: %v", err)
|
||||
}
|
||||
|
||||
edge2 := &channeldb.ChannelEdgeInfo{
|
||||
edge2 := &models.ChannelEdgeInfo{
|
||||
ChannelID: chanID2,
|
||||
NodeKey1Bytes: node1.PubKeyBytes,
|
||||
NodeKey2Bytes: node2.PubKeyBytes,
|
||||
BitcoinKey1Bytes: node1.PubKeyBytes,
|
||||
BitcoinKey2Bytes: node2.PubKeyBytes,
|
||||
AuthProof: &channeldb.ChannelAuthProof{
|
||||
AuthProof: &models.ChannelAuthProof{
|
||||
NodeSig1Bytes: testSig.Serialize(),
|
||||
NodeSig2Bytes: testSig.Serialize(),
|
||||
BitcoinSig1Bytes: testSig.Serialize(),
|
||||
@@ -2061,11 +2062,11 @@ func TestRouterChansClosedOfflinePruneGraph(t *testing.T) {
|
||||
require.NoError(t, err, "unable to create test node")
|
||||
node2, err := createTestNode()
|
||||
require.NoError(t, err, "unable to create test node")
|
||||
edge1 := &channeldb.ChannelEdgeInfo{
|
||||
edge1 := &models.ChannelEdgeInfo{
|
||||
ChannelID: chanID1.ToUint64(),
|
||||
NodeKey1Bytes: node1.PubKeyBytes,
|
||||
NodeKey2Bytes: node2.PubKeyBytes,
|
||||
AuthProof: &channeldb.ChannelAuthProof{
|
||||
AuthProof: &models.ChannelAuthProof{
|
||||
NodeSig1Bytes: testSig.Serialize(),
|
||||
NodeSig2Bytes: testSig.Serialize(),
|
||||
BitcoinSig1Bytes: testSig.Serialize(),
|
||||
@@ -2500,7 +2501,7 @@ func TestIsStaleNode(t *testing.T) {
|
||||
}
|
||||
ctx.chain.addBlock(fundingBlock, chanID.BlockHeight, chanID.BlockHeight)
|
||||
|
||||
edge := &channeldb.ChannelEdgeInfo{
|
||||
edge := &models.ChannelEdgeInfo{
|
||||
ChannelID: chanID.ToUint64(),
|
||||
NodeKey1Bytes: pub1,
|
||||
NodeKey2Bytes: pub2,
|
||||
@@ -2576,7 +2577,7 @@ func TestIsKnownEdge(t *testing.T) {
|
||||
}
|
||||
ctx.chain.addBlock(fundingBlock, chanID.BlockHeight, chanID.BlockHeight)
|
||||
|
||||
edge := &channeldb.ChannelEdgeInfo{
|
||||
edge := &models.ChannelEdgeInfo{
|
||||
ChannelID: chanID.ToUint64(),
|
||||
NodeKey1Bytes: pub1,
|
||||
NodeKey2Bytes: pub2,
|
||||
@@ -2632,7 +2633,7 @@ func TestIsStaleEdgePolicy(t *testing.T) {
|
||||
t.Fatalf("router failed to detect fresh edge policy")
|
||||
}
|
||||
|
||||
edge := &channeldb.ChannelEdgeInfo{
|
||||
edge := &models.ChannelEdgeInfo{
|
||||
ChannelID: chanID.ToUint64(),
|
||||
NodeKey1Bytes: pub1,
|
||||
NodeKey2Bytes: pub2,
|
||||
@@ -2645,7 +2646,7 @@ func TestIsStaleEdgePolicy(t *testing.T) {
|
||||
}
|
||||
|
||||
// We'll also add two edge policies, one for each direction.
|
||||
edgePolicy := &channeldb.ChannelEdgePolicy{
|
||||
edgePolicy := &models.ChannelEdgePolicy{
|
||||
SigBytes: testSig.Serialize(),
|
||||
ChannelID: edge.ChannelID,
|
||||
LastUpdate: updateTimeStamp,
|
||||
@@ -2659,7 +2660,7 @@ func TestIsStaleEdgePolicy(t *testing.T) {
|
||||
t.Fatalf("unable to update edge policy: %v", err)
|
||||
}
|
||||
|
||||
edgePolicy = &channeldb.ChannelEdgePolicy{
|
||||
edgePolicy = &models.ChannelEdgePolicy{
|
||||
SigBytes: testSig.Serialize(),
|
||||
ChannelID: edge.ChannelID,
|
||||
LastUpdate: updateTimeStamp,
|
||||
@@ -3202,7 +3203,7 @@ func TestGetPathEdges(t *testing.T) {
|
||||
bandwidthHints *bandwidthManager
|
||||
hops []route.Vertex
|
||||
|
||||
expectedEdges []*channeldb.CachedEdgePolicy
|
||||
expectedEdges []*models.CachedEdgePolicy
|
||||
expectedAmt lnwire.MilliSatoshi
|
||||
expectedErr string
|
||||
}{{
|
||||
@@ -3257,7 +3258,7 @@ const (
|
||||
// newChannelEdgeInfo is a helper function used to create a new channel edge,
|
||||
// possibly skipping adding it to parts of the chain/state as well.
|
||||
func newChannelEdgeInfo(ctx *testCtx, fundingHeight uint32,
|
||||
ecm edgeCreationModifier) (*channeldb.ChannelEdgeInfo, error) {
|
||||
ecm edgeCreationModifier) (*models.ChannelEdgeInfo, error) {
|
||||
|
||||
node1, err := createTestNode()
|
||||
if err != nil {
|
||||
@@ -3276,7 +3277,7 @@ func newChannelEdgeInfo(ctx *testCtx, fundingHeight uint32,
|
||||
return nil, fmt.Errorf("unable to create edge: %w", err)
|
||||
}
|
||||
|
||||
edge := &channeldb.ChannelEdgeInfo{
|
||||
edge := &models.ChannelEdgeInfo{
|
||||
ChannelID: chanID.ToUint64(),
|
||||
NodeKey1Bytes: node1.PubKeyBytes,
|
||||
NodeKey2Bytes: node2.PubKeyBytes,
|
||||
@@ -3307,7 +3308,7 @@ func newChannelEdgeInfo(ctx *testCtx, fundingHeight uint32,
|
||||
}
|
||||
|
||||
func assertChanChainRejection(t *testing.T, ctx *testCtx,
|
||||
edge *channeldb.ChannelEdgeInfo, failCode errorCode) {
|
||||
edge *models.ChannelEdgeInfo, failCode errorCode) {
|
||||
|
||||
t.Helper()
|
||||
|
||||
@@ -4715,7 +4716,7 @@ func TestNewRouteRequest(t *testing.T) {
|
||||
name: "hints and blinded",
|
||||
blindedPayment: blindedMultiHop,
|
||||
routeHints: make(
|
||||
map[route.Vertex][]*channeldb.CachedEdgePolicy,
|
||||
map[route.Vertex][]*models.CachedEdgePolicy,
|
||||
),
|
||||
err: ErrHintsAndBlinded,
|
||||
},
|
||||
|
||||
@@ -3,6 +3,7 @@ package routing
|
||||
import (
|
||||
"github.com/btcsuite/btcd/btcutil"
|
||||
"github.com/lightningnetwork/lnd/channeldb"
|
||||
"github.com/lightningnetwork/lnd/channeldb/models"
|
||||
"github.com/lightningnetwork/lnd/lntypes"
|
||||
"github.com/lightningnetwork/lnd/lnwire"
|
||||
"github.com/lightningnetwork/lnd/routing/route"
|
||||
@@ -41,7 +42,7 @@ func newNodeEdgeUnifier(sourceNode, toNode route.Vertex,
|
||||
// addPolicy adds a single channel policy. Capacity may be zero if unknown
|
||||
// (light clients).
|
||||
func (u *nodeEdgeUnifier) addPolicy(fromNode route.Vertex,
|
||||
edge *channeldb.CachedEdgePolicy, capacity btcutil.Amount) {
|
||||
edge *models.CachedEdgePolicy, capacity btcutil.Amount) {
|
||||
|
||||
localChan := fromNode == u.sourceNode
|
||||
|
||||
@@ -93,7 +94,7 @@ func (u *nodeEdgeUnifier) addGraphPolicies(g routingGraph) error {
|
||||
// unifiedEdge is the individual channel data that is kept inside an edgeUnifier
|
||||
// object.
|
||||
type unifiedEdge struct {
|
||||
policy *channeldb.CachedEdgePolicy
|
||||
policy *models.CachedEdgePolicy
|
||||
capacity btcutil.Amount
|
||||
}
|
||||
|
||||
@@ -233,7 +234,7 @@ func (u *edgeUnifier) getEdgeLocal(amt lnwire.MilliSatoshi,
|
||||
// forwarding context.
|
||||
func (u *edgeUnifier) getEdgeNetwork(amt lnwire.MilliSatoshi) *unifiedEdge {
|
||||
var (
|
||||
bestPolicy *channeldb.CachedEdgePolicy
|
||||
bestPolicy *models.CachedEdgePolicy
|
||||
maxFee lnwire.MilliSatoshi
|
||||
maxTimelock uint16
|
||||
maxCapMsat lnwire.MilliSatoshi
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/btcsuite/btcd/btcutil"
|
||||
"github.com/lightningnetwork/lnd/channeldb"
|
||||
"github.com/lightningnetwork/lnd/channeldb/models"
|
||||
"github.com/lightningnetwork/lnd/lnwire"
|
||||
"github.com/lightningnetwork/lnd/routing/route"
|
||||
"github.com/stretchr/testify/require"
|
||||
@@ -21,7 +21,7 @@ func TestNodeEdgeUnifier(t *testing.T) {
|
||||
bandwidthHints := &mockBandwidthHints{}
|
||||
|
||||
// Add two channels between the pair of nodes.
|
||||
p1 := channeldb.CachedEdgePolicy{
|
||||
p1 := models.CachedEdgePolicy{
|
||||
FeeProportionalMillionths: 100000,
|
||||
FeeBaseMSat: 30,
|
||||
TimeLockDelta: 60,
|
||||
@@ -29,7 +29,7 @@ func TestNodeEdgeUnifier(t *testing.T) {
|
||||
MaxHTLC: 5000,
|
||||
MinHTLC: 100,
|
||||
}
|
||||
p2 := channeldb.CachedEdgePolicy{
|
||||
p2 := models.CachedEdgePolicy{
|
||||
FeeProportionalMillionths: 190000,
|
||||
FeeBaseMSat: 10,
|
||||
TimeLockDelta: 40,
|
||||
@@ -49,7 +49,7 @@ func TestNodeEdgeUnifier(t *testing.T) {
|
||||
unifierNoCapacity.addPolicy(fromNode, &p2, 0)
|
||||
|
||||
unifierNoInfo := newNodeEdgeUnifier(source, toNode, nil)
|
||||
unifierNoInfo.addPolicy(fromNode, &channeldb.CachedEdgePolicy{}, 0)
|
||||
unifierNoInfo.addPolicy(fromNode, &models.CachedEdgePolicy{}, 0)
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"sync"
|
||||
|
||||
"github.com/lightningnetwork/lnd/channeldb"
|
||||
"github.com/lightningnetwork/lnd/channeldb/models"
|
||||
"github.com/lightningnetwork/lnd/lnwire"
|
||||
"github.com/lightningnetwork/lnd/routing/route"
|
||||
)
|
||||
@@ -125,7 +126,7 @@ func (v *ValidationBarrier) InitJobDependencies(job interface{}) {
|
||||
v.nodeAnnDependencies[route.Vertex(msg.NodeID1)] = signals
|
||||
v.nodeAnnDependencies[route.Vertex(msg.NodeID2)] = signals
|
||||
}
|
||||
case *channeldb.ChannelEdgeInfo:
|
||||
case *models.ChannelEdgeInfo:
|
||||
|
||||
shortID := lnwire.NewShortChanIDFromInt(msg.ChannelID)
|
||||
if _, ok := v.chanAnnFinSignal[shortID]; !ok {
|
||||
@@ -143,7 +144,7 @@ func (v *ValidationBarrier) InitJobDependencies(job interface{}) {
|
||||
|
||||
// These other types don't have any dependants, so no further
|
||||
// initialization needs to be done beyond just occupying a job slot.
|
||||
case *channeldb.ChannelEdgePolicy:
|
||||
case *models.ChannelEdgePolicy:
|
||||
return
|
||||
case *lnwire.ChannelUpdate:
|
||||
return
|
||||
@@ -187,7 +188,7 @@ func (v *ValidationBarrier) WaitForDependants(job interface{}) error {
|
||||
switch msg := job.(type) {
|
||||
// Any ChannelUpdate or NodeAnnouncement jobs will need to wait on the
|
||||
// completion of any active ChannelAnnouncement jobs related to them.
|
||||
case *channeldb.ChannelEdgePolicy:
|
||||
case *models.ChannelEdgePolicy:
|
||||
shortID := lnwire.NewShortChanIDFromInt(msg.ChannelID)
|
||||
signals, ok = v.chanEdgeDependencies[shortID]
|
||||
|
||||
@@ -217,7 +218,7 @@ func (v *ValidationBarrier) WaitForDependants(job interface{}) error {
|
||||
// return directly.
|
||||
case *lnwire.AnnounceSignatures:
|
||||
// TODO(roasbeef): need to wait on chan ann?
|
||||
case *channeldb.ChannelEdgeInfo:
|
||||
case *models.ChannelEdgeInfo:
|
||||
case *lnwire.ChannelAnnouncement:
|
||||
}
|
||||
|
||||
@@ -263,7 +264,7 @@ func (v *ValidationBarrier) SignalDependants(job interface{}, allow bool) {
|
||||
// If we've just finished executing a ChannelAnnouncement, then we'll
|
||||
// close out the signal, and remove the signal from the map of active
|
||||
// ones. This will allow/deny any dependent jobs to continue execution.
|
||||
case *channeldb.ChannelEdgeInfo:
|
||||
case *models.ChannelEdgeInfo:
|
||||
shortID := lnwire.NewShortChanIDFromInt(msg.ChannelID)
|
||||
finSignals, ok := v.chanAnnFinSignal[shortID]
|
||||
if ok {
|
||||
@@ -296,7 +297,7 @@ func (v *ValidationBarrier) SignalDependants(job interface{}, allow bool) {
|
||||
delete(v.nodeAnnDependencies, route.Vertex(msg.NodeID))
|
||||
case *lnwire.ChannelUpdate:
|
||||
delete(v.chanEdgeDependencies, msg.ShortChannelID)
|
||||
case *channeldb.ChannelEdgePolicy:
|
||||
case *models.ChannelEdgePolicy:
|
||||
shortID := lnwire.NewShortChanIDFromInt(msg.ChannelID)
|
||||
delete(v.chanEdgeDependencies, shortID)
|
||||
|
||||
|
||||
Reference in new issue
Block a user