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.
This commit is contained in:
Keagan McClelland 2024-03-03 11:53:39 -08:00
parent 3761912680
commit f5f0286e34
3 changed files with 9 additions and 9 deletions

View File

@ -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) {

View File

@ -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)

View File

@ -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 {