mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-09-01 18:27:43 +02:00
protofsm: add new ConfMapper similar to SpendMapper for conf events
In this commit, we add a new ConfMapper which is useful for state machines that want to project some of the conf attributes into a new event to be sent post conf.
This commit is contained in:
@@ -522,16 +522,19 @@ func (s *StateMachine[Event, Env]) executeDaemonEvent(ctx context.Context,
|
||||
launched := s.gm.Go(ctx, func(ctx context.Context) {
|
||||
for {
|
||||
select {
|
||||
case <-confEvent.Confirmed:
|
||||
// If there's a post-conf event, then
|
||||
//nolint:ll
|
||||
case conf, ok := <-confEvent.Confirmed:
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
|
||||
// If there's a post-conf mapper, then
|
||||
// we'll send that into the current
|
||||
// state now.
|
||||
//
|
||||
// TODO(roasbeef): refactor to
|
||||
// dispatchAfterRecv w/ above
|
||||
postConf := daemonEvent.PostConfEvent
|
||||
postConf.WhenSome(func(e Event) {
|
||||
s.SendEvent(ctx, e)
|
||||
postConfMapper := daemonEvent.PostConfMapper
|
||||
postConfMapper.WhenSome(func(f ConfMapper[Event]) {
|
||||
customEvent := f(conf)
|
||||
s.SendEvent(ctx, customEvent)
|
||||
})
|
||||
|
||||
return
|
||||
|
Reference in New Issue
Block a user