mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-04-20 21:44:39 +02:00
peer: update readHandler to dispatch to msgRouter if set
Over time with this, we should be able to significantly reduce the size of the peer.Brontide struct as we only need all those deps as the peer needs to recognize and handle each incoming wire message itself.
This commit is contained in:
parent
ba6f01d48b
commit
fbbd8df487
@ -493,6 +493,10 @@ type Brontide struct {
|
||||
// potentially holding lots of un-consumed events.
|
||||
channelEventClient *subscribe.Client
|
||||
|
||||
// msgRouter is an instance of the MsgRouter which is used to send off
|
||||
// new wire messages for handing.
|
||||
msgRouter fn.Option[MsgRouter]
|
||||
|
||||
startReady chan struct{}
|
||||
quit chan struct{}
|
||||
wg sync.WaitGroup
|
||||
@ -530,6 +534,7 @@ func NewBrontide(cfg Config) *Brontide {
|
||||
startReady: make(chan struct{}),
|
||||
quit: make(chan struct{}),
|
||||
log: build.NewPrefixLog(logPrefix, peerLog),
|
||||
msgRouter: fn.Some[MsgRouter](NewMultiMsgRouter()),
|
||||
}
|
||||
|
||||
var (
|
||||
@ -1708,6 +1713,19 @@ out:
|
||||
}
|
||||
}
|
||||
|
||||
// If a message router is active, then we'll try to have it
|
||||
// handle this message. If it can, then we're able to skip the
|
||||
// rest of the message handling logic.
|
||||
ok := fn.MapOptionZ(p.msgRouter, func(r MsgRouter) error {
|
||||
return r.RouteMsg(nextMsg)
|
||||
})
|
||||
|
||||
// No error occurred, and the message was handled by the
|
||||
// router.
|
||||
if ok == nil {
|
||||
continue
|
||||
}
|
||||
|
||||
var (
|
||||
targetChan lnwire.ChannelID
|
||||
isLinkUpdate bool
|
||||
|
Loading…
x
Reference in New Issue
Block a user