htlcswitch: add a new UpdateFeePolicy to ChannelLink interface
This commit adds a new method to the ChannelLink interface which is meant to allow outside sub-system to update the forwarding policy of a channel. This can be triggered either by a new RPC method, or automatically by some sort of control system which seeks to optimize fee revenue, or block off channels, etc.
This commit is contained in:
parent
cd10dc712f
commit
399d193e2c
@ -57,8 +57,17 @@ type ChannelLink interface {
|
||||
// short channel ID encodes the exact location in the main chain that
|
||||
// the original funding output can be found.
|
||||
ShortChanID() lnwire.ShortChannelID
|
||||
|
||||
// UpdateForwardingPolicy updates the forwarding policy for the target
|
||||
// ChannelLink. Once updated, the link will use the new forwarding
|
||||
// policy to govern if it an incoming HTLC should be forwarded or not.
|
||||
UpdateForwardingPolicy(ForwardingPolicy)
|
||||
|
||||
// Bandwidth returns the amount of satoshis which current link might
|
||||
// pass through channel link.
|
||||
// pass through channel link. The value returned from this method
|
||||
// represents the up to date available flow through the channel. This
|
||||
// takes into account any forwarded but un-cleared HTLC's, and any
|
||||
// HTLC's which have been set to the over flow queue.
|
||||
Bandwidth() btcutil.Amount
|
||||
|
||||
// Stats return the statistics of channel link. Number of updates,
|
||||
|
@ -740,6 +740,36 @@ func (l *channelLink) getBandwidth() btcutil.Amount {
|
||||
return l.channel.LocalAvailableBalance() - l.overflowQueue.pendingAmount()
|
||||
}
|
||||
|
||||
// policyUpdate is a message sent to a channel link when an outside sub-system
|
||||
// wishes to update the current forwarding policy.
|
||||
type policyUpdate struct {
|
||||
policy ForwardingPolicy
|
||||
|
||||
done chan struct{}
|
||||
}
|
||||
|
||||
// UpdateForwardingPolicy updates the forwarding policy for the target
|
||||
// ChannelLink. Once updated, the link will use the new forwarding policy to
|
||||
// govern if it an incoming HTLC should be forwarded or not.
|
||||
//
|
||||
// NOTE: Part of the ChannelLink interface.
|
||||
func (l *channelLink) UpdateForwardingPolicy(newPolicy ForwardingPolicy) {
|
||||
cmd := &policyUpdate{
|
||||
policy: newPolicy,
|
||||
done: make(chan struct{}),
|
||||
}
|
||||
|
||||
select {
|
||||
case l.linkControl <- cmd:
|
||||
case <-l.quit:
|
||||
}
|
||||
|
||||
select {
|
||||
case <-cmd.done:
|
||||
case <-l.quit:
|
||||
}
|
||||
}
|
||||
|
||||
// Stats returns the statistics of channel link.
|
||||
//
|
||||
// NOTE: Part of the ChannelLink interface.
|
||||
|
Loading…
Reference in New Issue
Block a user