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:
Olaoluwa Osuntokun committed 2025-06-03 16:27:28 -07:00
1 parent 239aab8b9e
commit cb46f3daa0
3 files changed
+175 -12

No files matched your search

+7 -4
View File
@@ -72,6 +72,10 @@ func (b *BroadcastTxn) daemonSealed() {}
// custom state machine event.
type SpendMapper[Event any] func(*chainntnfs.SpendDetail) Event
// ConfMapper is a function that's used to map a confirmation notification to a
// custom state machine event.
type ConfMapper[Event any] func(*chainntnfs.TxConfirmation) Event
// RegisterSpend is used to request that a certain event is sent into the state
// machine once the specified outpoint has been spent.
type RegisterSpend[Event any] struct {
@@ -112,10 +116,9 @@ type RegisterConf[Event any] struct {
// transaction needs to dispatch an event.
NumConfs fn.Option[uint32]
// PostConfEvent is an event that's sent back to the requester once the
// transaction specified above has confirmed in the chain with
// sufficient depth.
PostConfEvent fn.Option[Event]
// PostConfMapper is a special conf mapper, that if present, will be
// used to map the protofsm confirmation event to a custom event.
PostConfMapper fn.Option[ConfMapper[Event]]
}
// daemonSealed indicates that this struct is a DaemonEvent instance.