From f5f0286e3400049e81b2adb86966e4610e54d225 Mon Sep 17 00:00:00 2001 From: Keagan McClelland Date: Sun, 3 Mar 2024 11:53:39 -0800 Subject: [PATCH] peer+lnwire: move LinkUpdater to lnwire The purpose of this interface is to distinguish messages that are bound to a particular channel_id from those that are not. There is no reason this ought to be a property of the peer package as it is entirely determined by the contents of the message itself. Therefore we move it to the lnwire package so it can be used without having import cycles elsewhere in the codebase. --- lnwire/message.go | 8 ++++++++ peer/brontide.go | 2 +- peer/interfaces.go | 8 -------- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lnwire/message.go b/lnwire/message.go index 634f78ab3..0f28a2465 100644 --- a/lnwire/message.go +++ b/lnwire/message.go @@ -190,6 +190,14 @@ type Message interface { MsgType() MessageType } +// LinkUpdater is an interface implemented by most messages in BOLT 2 that are +// allowed to update the channel state. +type LinkUpdater interface { + // TargetChanID returns the channel id of the link for which this + // message is intended. + TargetChanID() ChannelID +} + // makeEmptyMessage creates a new empty message of the proper concrete type // based on the passed message type. func makeEmptyMessage(msgType MessageType) (Message, error) { diff --git a/peer/brontide.go b/peer/brontide.go index 696ad8610..189fb1660 100644 --- a/peer/brontide.go +++ b/peer/brontide.go @@ -1750,7 +1750,7 @@ out: // will consider them as link updates and send them to // chanStream. These messages will be queued inside chanStream // if the channel is not active yet. - case LinkUpdater: + case lnwire.LinkUpdater: targetChan = msg.TargetChanID() isLinkUpdate = p.hasChannel(targetChan) diff --git a/peer/interfaces.go b/peer/interfaces.go index 562d89723..4f4619fef 100644 --- a/peer/interfaces.go +++ b/peer/interfaces.go @@ -34,14 +34,6 @@ type messageSwitch interface { error) } -// LinkUpdater is an interface implemented by most messages in BOLT 2 that are -// allowed to update the channel state. -type LinkUpdater interface { - // TargetChanID returns the channel id of the link for which this message - // is intended. - TargetChanID() lnwire.ChannelID -} - // MessageConn is an interface implemented by anything that delivers // an lnwire.Message using a net.Conn interface. type MessageConn interface {