mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-09-06 17:47:01 +02:00
htlcswitch: add link operation for initiating quiescence
This commit is contained in:
@@ -170,6 +170,18 @@ type ChannelUpdateHandler interface {
|
|||||||
// will only ever be called once. If no CommitSig is owed in the
|
// will only ever be called once. If no CommitSig is owed in the
|
||||||
// argument's LinkDirection, then we will call this hook immediately.
|
// argument's LinkDirection, then we will call this hook immediately.
|
||||||
OnCommitOnce(LinkDirection, func())
|
OnCommitOnce(LinkDirection, func())
|
||||||
|
|
||||||
|
// InitStfu allows us to initiate quiescence on this link. It returns
|
||||||
|
// a receive only channel that will block until quiescence has been
|
||||||
|
// achieved, or definitively fails. The return value is the
|
||||||
|
// ChannelParty who holds the role of initiator or Err if the operation
|
||||||
|
// fails.
|
||||||
|
//
|
||||||
|
// This operation has been added to allow channels to be quiesced via
|
||||||
|
// RPC. It may be removed or reworked in the future as RPC initiated
|
||||||
|
// quiescence is a holdover until we have downstream protocols that use
|
||||||
|
// it.
|
||||||
|
InitStfu() <-chan fn.Result[lntypes.ChannelParty]
|
||||||
}
|
}
|
||||||
|
|
||||||
// CommitHookID is a value that is used to uniquely identify hooks in the
|
// CommitHookID is a value that is used to uniquely identify hooks in the
|
||||||
|
@@ -737,6 +737,22 @@ func (l *channelLink) OnCommitOnce(direction LinkDirection, hook func()) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// InitStfu allows us to initiate quiescence on this link. It returns a receive
|
||||||
|
// only channel that will block until quiescence has been achieved, or
|
||||||
|
// definitively fails.
|
||||||
|
//
|
||||||
|
// This operation has been added to allow channels to be quiesced via RPC. It
|
||||||
|
// may be removed or reworked in the future as RPC initiated quiescence is a
|
||||||
|
// holdover until we have downstream protocols that use it.
|
||||||
|
func (l *channelLink) InitStfu() <-chan fn.Result[lntypes.ChannelParty] {
|
||||||
|
// TODO(proofofkeags): Implement
|
||||||
|
c := make(chan fn.Result[lntypes.ChannelParty], 1)
|
||||||
|
|
||||||
|
c <- fn.Errf[lntypes.ChannelParty]("InitStfu not yet implemented")
|
||||||
|
|
||||||
|
return c
|
||||||
|
}
|
||||||
|
|
||||||
// isReestablished returns true if the link has successfully completed the
|
// isReestablished returns true if the link has successfully completed the
|
||||||
// channel reestablishment dance.
|
// channel reestablishment dance.
|
||||||
func (l *channelLink) isReestablished() bool {
|
func (l *channelLink) isReestablished() bool {
|
||||||
|
@@ -950,6 +950,14 @@ func (f *mockChannelLink) OnFlushedOnce(func()) {
|
|||||||
func (f *mockChannelLink) OnCommitOnce(LinkDirection, func()) {
|
func (f *mockChannelLink) OnCommitOnce(LinkDirection, func()) {
|
||||||
// TODO(proofofkeags): Implement
|
// TODO(proofofkeags): Implement
|
||||||
}
|
}
|
||||||
|
func (f *mockChannelLink) InitStfu() <-chan fn.Result[lntypes.ChannelParty] {
|
||||||
|
// TODO(proofofkeags): Implement
|
||||||
|
c := make(chan fn.Result[lntypes.ChannelParty], 1)
|
||||||
|
|
||||||
|
c <- fn.Errf[lntypes.ChannelParty]("InitStfu not implemented")
|
||||||
|
|
||||||
|
return c
|
||||||
|
}
|
||||||
|
|
||||||
func (f *mockChannelLink) FundingCustomBlob() fn.Option[tlv.Blob] {
|
func (f *mockChannelLink) FundingCustomBlob() fn.Option[tlv.Blob] {
|
||||||
return fn.None[tlv.Blob]()
|
return fn.None[tlv.Blob]()
|
||||||
|
@@ -24,6 +24,7 @@ import (
|
|||||||
"github.com/lightningnetwork/lnd/keychain"
|
"github.com/lightningnetwork/lnd/keychain"
|
||||||
"github.com/lightningnetwork/lnd/lntest/channels"
|
"github.com/lightningnetwork/lnd/lntest/channels"
|
||||||
"github.com/lightningnetwork/lnd/lntest/mock"
|
"github.com/lightningnetwork/lnd/lntest/mock"
|
||||||
|
"github.com/lightningnetwork/lnd/lntypes"
|
||||||
"github.com/lightningnetwork/lnd/lnwallet"
|
"github.com/lightningnetwork/lnd/lnwallet"
|
||||||
"github.com/lightningnetwork/lnd/lnwallet/chainfee"
|
"github.com/lightningnetwork/lnd/lnwallet/chainfee"
|
||||||
"github.com/lightningnetwork/lnd/lnwire"
|
"github.com/lightningnetwork/lnd/lnwire"
|
||||||
@@ -477,6 +478,14 @@ func (m *mockUpdateHandler) OnCommitOnce(
|
|||||||
|
|
||||||
hook()
|
hook()
|
||||||
}
|
}
|
||||||
|
func (m *mockUpdateHandler) InitStfu() <-chan fn.Result[lntypes.ChannelParty] {
|
||||||
|
// TODO(proofofkeags): Implement
|
||||||
|
c := make(chan fn.Result[lntypes.ChannelParty], 1)
|
||||||
|
|
||||||
|
c <- fn.Errf[lntypes.ChannelParty]("InitStfu not yet implemented")
|
||||||
|
|
||||||
|
return c
|
||||||
|
}
|
||||||
|
|
||||||
func newMockConn(t *testing.T, expectedMessages int) *mockMessageConn {
|
func newMockConn(t *testing.T, expectedMessages int) *mockMessageConn {
|
||||||
return &mockMessageConn{
|
return &mockMessageConn{
|
||||||
|
Reference in New Issue
Block a user