peer+chancloser: tryLinkShutdown during cooperative close process

Adds a new Brontide struct method tryLinkShutdown that attempts to
fetch the target link and calls ShutdownIfChannelClean on it. This
allows the coop close process to guarantee atomicity of the underlying
channel state. Also removes the UnregisterChannel method from the
chancloser's config as the link is shut down before the chancloser
is created.
This commit is contained in:
eugene
2021-08-10 17:00:51 -04:00
parent 608d11dcbc
commit aeaa009e92
4 changed files with 110 additions and 49 deletions

View File

@@ -380,7 +380,9 @@ func createTestPeer(notifier chainntnfs.ChainNotifier,
// mockMessageSwitch is a mock implementation of the messageSwitch interface
// used for testing without relying on a *htlcswitch.Switch in unit tests.
type mockMessageSwitch struct{}
type mockMessageSwitch struct {
links []htlcswitch.ChannelUpdateHandler
}
// BestHeight currently returns a dummy value.
func (m *mockMessageSwitch) BestHeight() uint32 {
@@ -402,11 +404,11 @@ func (m *mockMessageSwitch) CreateAndAddLink(cfg htlcswitch.ChannelLinkConfig,
return nil
}
// GetLinksByInterface currently returns dummy values.
// GetLinksByInterface returns the active links.
func (m *mockMessageSwitch) GetLinksByInterface(pub [33]byte) (
[]htlcswitch.ChannelUpdateHandler, error) {
return nil, nil
return m.links, nil
}
// mockUpdateHandler is a mock implementation of the ChannelUpdateHandler