mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-09-06 17:47:01 +02:00
htlcswitch: implement flush api for channelLink
This commit is contained in:
@@ -367,6 +367,14 @@ type channelLink struct {
|
||||
// log is a link-specific logging instance.
|
||||
log btclog.Logger
|
||||
|
||||
// isOutgoingAddBlocked tracks whether the channelLink can send an
|
||||
// UpdateAddHTLC.
|
||||
isOutgoingAddBlocked atomic.Bool
|
||||
|
||||
// isIncomingAddBlocked tracks whether the channelLink can receive an
|
||||
// UpdateAddHTLC.
|
||||
isIncomingAddBlocked atomic.Bool
|
||||
|
||||
wg sync.WaitGroup
|
||||
quit chan struct{}
|
||||
}
|
||||
@@ -559,24 +567,49 @@ func (l *channelLink) EligibleToUpdate() bool {
|
||||
// EnableAdds sets the ChannelUpdateHandler state to allow UpdateAddHtlc's in
|
||||
// the specified direction. It returns an error if the state already allowed
|
||||
// those adds.
|
||||
func (l *channelLink) EnableAdds(LinkDirection) error {
|
||||
// TODO(proofofkeags): Implement
|
||||
func (l *channelLink) EnableAdds(linkDirection LinkDirection) error {
|
||||
if linkDirection == Outgoing {
|
||||
if !l.isOutgoingAddBlocked.Swap(false) {
|
||||
return errors.New("outgoing adds already enabled")
|
||||
}
|
||||
}
|
||||
|
||||
if linkDirection == Incoming {
|
||||
if !l.isIncomingAddBlocked.Swap(false) {
|
||||
return errors.New("incoming adds already enabled")
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// DiableAdds sets the ChannelUpdateHandler state to allow UpdateAddHtlc's in
|
||||
// the specified direction. It returns an error if the state already disallowed
|
||||
// those adds.
|
||||
func (l *channelLink) DisableAdds(LinkDirection) error {
|
||||
// TODO(proofofkeags): Implement
|
||||
func (l *channelLink) DisableAdds(linkDirection LinkDirection) error {
|
||||
if linkDirection == Outgoing {
|
||||
if l.isOutgoingAddBlocked.Swap(true) {
|
||||
return errors.New("outgoing adds already disabled")
|
||||
}
|
||||
}
|
||||
|
||||
if linkDirection == Incoming {
|
||||
if l.isIncomingAddBlocked.Swap(true) {
|
||||
return errors.New("incoming adds already disabled")
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// IsFlushing returns true when UpdateAddHtlc's are disabled in the direction of
|
||||
// the argument.
|
||||
func (l *channelLink) IsFlushing(LinkDirection) bool {
|
||||
// TODO(proofofkeags): Implement
|
||||
return false
|
||||
func (l *channelLink) IsFlushing(linkDirection LinkDirection) bool {
|
||||
if linkDirection == Outgoing {
|
||||
return l.isOutgoingAddBlocked.Load()
|
||||
}
|
||||
|
||||
return l.isIncomingAddBlocked.Load()
|
||||
}
|
||||
|
||||
// OnFlushedOnce adds a hook that will be called the next time the
|
||||
|
Reference in New Issue
Block a user