routing: add clock to router config
This commit is contained in:
parent
c357511051
commit
8558534417
@ -17,6 +17,7 @@ import (
|
|||||||
|
|
||||||
sphinx "github.com/lightningnetwork/lightning-onion"
|
sphinx "github.com/lightningnetwork/lightning-onion"
|
||||||
"github.com/lightningnetwork/lnd/channeldb"
|
"github.com/lightningnetwork/lnd/channeldb"
|
||||||
|
"github.com/lightningnetwork/lnd/clock"
|
||||||
"github.com/lightningnetwork/lnd/htlcswitch"
|
"github.com/lightningnetwork/lnd/htlcswitch"
|
||||||
"github.com/lightningnetwork/lnd/input"
|
"github.com/lightningnetwork/lnd/input"
|
||||||
"github.com/lightningnetwork/lnd/lntypes"
|
"github.com/lightningnetwork/lnd/lntypes"
|
||||||
@ -302,6 +303,9 @@ type Config struct {
|
|||||||
|
|
||||||
// PathFindingConfig defines global path finding parameters.
|
// PathFindingConfig defines global path finding parameters.
|
||||||
PathFindingConfig PathFindingConfig
|
PathFindingConfig PathFindingConfig
|
||||||
|
|
||||||
|
// Clock is mockable time provider.
|
||||||
|
Clock clock.Clock
|
||||||
}
|
}
|
||||||
|
|
||||||
// EdgeLocator is a struct used to identify a specific edge.
|
// EdgeLocator is a struct used to identify a specific edge.
|
||||||
@ -1680,7 +1684,7 @@ func (r *ChannelRouter) preparePayment(payment *LightningPayment) (
|
|||||||
info := &channeldb.PaymentCreationInfo{
|
info := &channeldb.PaymentCreationInfo{
|
||||||
PaymentHash: payment.PaymentHash,
|
PaymentHash: payment.PaymentHash,
|
||||||
Value: payment.Amount,
|
Value: payment.Amount,
|
||||||
CreationTime: time.Now(),
|
CreationTime: r.cfg.Clock.Now(),
|
||||||
PaymentRequest: payment.PaymentRequest,
|
PaymentRequest: payment.PaymentRequest,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1709,7 +1713,7 @@ func (r *ChannelRouter) SendToRoute(hash lntypes.Hash, route *route.Route) (
|
|||||||
info := &channeldb.PaymentCreationInfo{
|
info := &channeldb.PaymentCreationInfo{
|
||||||
PaymentHash: hash,
|
PaymentHash: hash,
|
||||||
Value: amt,
|
Value: amt,
|
||||||
CreationTime: time.Now(),
|
CreationTime: r.cfg.Clock.Now(),
|
||||||
PaymentRequest: nil,
|
PaymentRequest: nil,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,6 +19,7 @@ import (
|
|||||||
"github.com/davecgh/go-spew/spew"
|
"github.com/davecgh/go-spew/spew"
|
||||||
|
|
||||||
"github.com/lightningnetwork/lnd/channeldb"
|
"github.com/lightningnetwork/lnd/channeldb"
|
||||||
|
"github.com/lightningnetwork/lnd/clock"
|
||||||
"github.com/lightningnetwork/lnd/htlcswitch"
|
"github.com/lightningnetwork/lnd/htlcswitch"
|
||||||
"github.com/lightningnetwork/lnd/lntypes"
|
"github.com/lightningnetwork/lnd/lntypes"
|
||||||
"github.com/lightningnetwork/lnd/lnwire"
|
"github.com/lightningnetwork/lnd/lnwire"
|
||||||
@ -131,6 +132,7 @@ func createTestCtxFromGraphInstance(startingHeight uint32, graphInstance *testGr
|
|||||||
return next, nil
|
return next, nil
|
||||||
},
|
},
|
||||||
PathFindingConfig: pathFindingConfig,
|
PathFindingConfig: pathFindingConfig,
|
||||||
|
Clock: clock.NewTestClock(time.Unix(1, 0)),
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, fmt.Errorf("unable to create router %v", err)
|
return nil, nil, fmt.Errorf("unable to create router %v", err)
|
||||||
@ -2967,6 +2969,7 @@ func TestRouterPaymentStateMachine(t *testing.T) {
|
|||||||
next := atomic.AddUint64(&uniquePaymentID, 1)
|
next := atomic.AddUint64(&uniquePaymentID, 1)
|
||||||
return next, nil
|
return next, nil
|
||||||
},
|
},
|
||||||
|
Clock: clock.NewTestClock(time.Unix(1, 0)),
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unable to create router %v", err)
|
t.Fatalf("unable to create router %v", err)
|
||||||
|
@ -740,6 +740,7 @@ func newServer(listenAddrs []net.Addr, chanDB *channeldb.DB,
|
|||||||
AssumeChannelValid: cfg.Routing.UseAssumeChannelValid(),
|
AssumeChannelValid: cfg.Routing.UseAssumeChannelValid(),
|
||||||
NextPaymentID: sequencer.NextID,
|
NextPaymentID: sequencer.NextID,
|
||||||
PathFindingConfig: pathFindingConfig,
|
PathFindingConfig: pathFindingConfig,
|
||||||
|
Clock: clock.NewDefaultClock(),
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("can't create router: %v", err)
|
return nil, fmt.Errorf("can't create router: %v", err)
|
||||||
|
Loading…
Reference in New Issue
Block a user