htlcswitch: add link operation for initiating quiescence

This commit is contained in:
Keagan McClelland 2024-03-12 11:43:48 -07:00
parent a085b59814
commit 70e3804121
No known key found for this signature in database
GPG Key ID: FA7E65C951F12439
4 changed files with 45 additions and 0 deletions

View File

@ -170,6 +170,18 @@ type ChannelUpdateHandler interface {
// will only ever be called once. If no CommitSig is owed in the
// argument's LinkDirection, then we will call this hook immediately.
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

View File

@ -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
// channel reestablishment dance.
func (l *channelLink) isReestablished() bool {

View File

@ -950,6 +950,14 @@ func (f *mockChannelLink) OnFlushedOnce(func()) {
func (f *mockChannelLink) OnCommitOnce(LinkDirection, func()) {
// 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] {
return fn.None[tlv.Blob]()

View File

@ -24,6 +24,7 @@ import (
"github.com/lightningnetwork/lnd/keychain"
"github.com/lightningnetwork/lnd/lntest/channels"
"github.com/lightningnetwork/lnd/lntest/mock"
"github.com/lightningnetwork/lnd/lntypes"
"github.com/lightningnetwork/lnd/lnwallet"
"github.com/lightningnetwork/lnd/lnwallet/chainfee"
"github.com/lightningnetwork/lnd/lnwire"
@ -477,6 +478,14 @@ func (m *mockUpdateHandler) OnCommitOnce(
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 {
return &mockMessageConn{