multi: make MsgRouter available in the ImplementationCfg
With this commit, we allow the `MsgRouter` to be available in the `ImplementationCfg`. With this, programs outside of lnd itself are able to now hook into the message processing flow to direct handle custom messages, and even normal wire messages.
This commit is contained in:
1 parent
927aa84b5f
commit
b028af1836
4 files changed
+33
-4
No files matched your search
+12
-3
@@ -387,6 +387,11 @@ type Config struct {
|
||||
// This value will be passed to created links.
|
||||
MaxFeeExposure lnwire.MilliSatoshi
|
||||
|
||||
// MsgRouter is an optional instance of the main message router that
|
||||
// the peer will use. If None, then a new default version will be used
|
||||
// in place.
|
||||
MsgRouter fn.Option[msgmux.Router]
|
||||
|
||||
// Quit is the server's quit channel. If this is closed, we halt operation.
|
||||
Quit chan struct{}
|
||||
}
|
||||
@@ -542,6 +547,12 @@ var _ lnpeer.Peer = (*Brontide)(nil)
|
||||
func NewBrontide(cfg Config) *Brontide {
|
||||
logPrefix := fmt.Sprintf("Peer(%x):", cfg.PubKeyBytes)
|
||||
|
||||
// We'll either use the msg router instance passed in, or create a new
|
||||
// blank instance.
|
||||
msgRouter := cfg.MsgRouter.Alt(fn.Some[msgmux.Router](
|
||||
msgmux.NewMultiMsgRouter(),
|
||||
))
|
||||
|
||||
p := &Brontide{
|
||||
cfg: cfg,
|
||||
activeSignal: make(chan struct{}),
|
||||
@@ -564,9 +575,7 @@ func NewBrontide(cfg Config) *Brontide {
|
||||
startReady: make(chan struct{}),
|
||||
quit: make(chan struct{}),
|
||||
log: build.NewPrefixLog(logPrefix, peerLog),
|
||||
msgRouter: fn.Some[msgmux.Router](
|
||||
msgmux.NewMultiMsgRouter(),
|
||||
),
|
||||
msgRouter: msgRouter,
|
||||
}
|
||||
|
||||
if cfg.Conn != nil && cfg.Conn.RemoteAddr() != nil {
|
||||
|
||||
Reference in new issue
Block a user