peer: load initial forwarding policy from channel DB
This commit is contained in:
1 parent
7ac445caaf
commit
fb36806724
1 file changed
+8
-16
+8
-16
@@ -3832,26 +3832,18 @@ func (p *Brontide) addActiveChannel(c *channeldb.OpenChannel) error {
|
|||||||
err)
|
err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// We'll query the localChanCfg of the new channel to determine the
|
// We'll query the channel DB for the new channel's initial forwarding
|
||||||
// minimum HTLC value that can be forwarded. For the maximum HTLC value
|
// policies to determine the policy we start out with.
|
||||||
// that can be forwarded and fees we'll use the default values, as they
|
initialPolicy, err := p.cfg.ChannelDB.GetInitialForwardingPolicy(chanID)
|
||||||
// currently are always set to the default values at initial channel
|
if err != nil {
|
||||||
// creation. Note that the maximum HTLC value defaults to the cap on
|
return fmt.Errorf("unable to query for initial forwarding "+
|
||||||
// the total value of outstanding HTLCs.
|
"policy: %v", err)
|
||||||
fwdMinHtlc := lnChan.FwdMinHtlc()
|
|
||||||
defaultPolicy := p.cfg.RoutingPolicy
|
|
||||||
forwardingPolicy := &models.ForwardingPolicy{
|
|
||||||
MinHTLCOut: fwdMinHtlc,
|
|
||||||
MaxHTLC: c.LocalChanCfg.MaxPendingAmount,
|
|
||||||
BaseFee: defaultPolicy.BaseFee,
|
|
||||||
FeeRate: defaultPolicy.FeeRate,
|
|
||||||
TimeLockDelta: defaultPolicy.TimeLockDelta,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the link and add it to the switch.
|
// Create the link and add it to the switch.
|
||||||
err = p.addLink(
|
err = p.addLink(
|
||||||
chanPoint, lnChan, forwardingPolicy,
|
chanPoint, lnChan, initialPolicy, chainEvents,
|
||||||
chainEvents, shouldReestablish,
|
shouldReestablish,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("can't register new channel link(%v) with "+
|
return fmt.Errorf("can't register new channel link(%v) with "+
|
||||||
|
|||||||
Reference in new issue
Block a user