protofsm: add ability for state machine to consume wire msgs

In this commit, we add the ability for the state machine to consume wire
messages. This'll allow the creation of a new generic message router
that takes the place of the current peer `readHandler` in an upcoming
commit.
This commit is contained in:
Olaoluwa Osuntokun
2024-01-25 17:22:00 -08:00
parent bf10e31167
commit 424ae09631
4 changed files with 166 additions and 17 deletions

15
protofsm/msg_mapper.go Normal file
View File

@@ -0,0 +1,15 @@
package protofsm
import (
"github.com/lightningnetwork/lnd/fn"
"github.com/lightningnetwork/lnd/lnwire"
)
// MsgMapper is used to map incoming wire messages into a FSM event. This is
// useful to decouple the translation of an outside or wire message into an
// event type that can be understood by the FSM.
type MsgMapper[Event any] interface {
// MapMsg maps a wire message into a FSM event. If the message is not
// mappable, then an None is returned.
MapMsg(msg lnwire.Message) fn.Option[Event]
}