Skip to content

Commit 7e062ed

Browse files
committed
supplycommit: add basic asset group state machine error reporter
1 parent 9118202 commit 7e062ed

File tree

1 file changed

+30
-3
lines changed

1 file changed

+30
-3
lines changed

universe/supplycommit/multi_sm_manager.go

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,10 +163,14 @@ func (m *MultiStateMachineManager) fetchStateMachine(
163163
// TODO(ffranr): Get initial state from disk here.
164164
initialState := &DefaultState{}
165165

166+
// Create a new error reporter for the state machine.
167+
errorReporter := NewErrorReporter(assetSpec)
168+
166169
fsmCfg := protofsm.StateMachineCfg[Event, *Environment]{
167-
InitialState: initialState,
168-
Env: env,
169-
Daemon: m.cfg.DaemonAdapters,
170+
ErrorReporter: &errorReporter,
171+
InitialState: initialState,
172+
Env: env,
173+
Daemon: m.cfg.DaemonAdapters,
170174
}
171175
newSm := protofsm.NewStateMachine[Event, *Environment](fsmCfg)
172176

@@ -426,3 +430,26 @@ func (c *stateMachineCache) Delete(groupPubKey btcec.PublicKey) {
426430

427431
delete(c.cache, serializedGroupKey)
428432
}
433+
434+
// ErrorReporter is an asset specific error reporter that can be used to
435+
// report errors that occur during the operation of the asset group supply
436+
// commitment state machine.
437+
type ErrorReporter struct {
438+
// assetSpec is the asset specifier that identifies the asset group.
439+
assetSpec asset.Specifier
440+
}
441+
442+
// NewErrorReporter creates a new ErrorReporter for the given asset specifier
443+
// state machine.
444+
func NewErrorReporter(assetSpec asset.Specifier) ErrorReporter {
445+
return ErrorReporter{
446+
assetSpec: assetSpec,
447+
}
448+
}
449+
450+
// ReportError reports an error that occurred during the operation of the
451+
// asset group supply commitment state machine.
452+
func (r *ErrorReporter) ReportError(err error) {
453+
log.Errorf("supply commit state machine (asset_spec=%s): %v",
454+
r.assetSpec.String(), err)
455+
}

0 commit comments

Comments
 (0)