protofsm: add String() method to ProtocolState

This commit is contained in:
Olaoluwa Osuntokun
2025-02-07 18:17:27 -08:00
parent 01382f4c2a
commit 1d2c22d140
3 changed files with 65 additions and 3 deletions

View File

@@ -77,7 +77,8 @@ type State[Event any, Env Environment] interface {
// otherwise.
IsTerminal() bool
// TODO(roasbeef): also add state serialization?
// String returns a human readable string that represents the state.
String() string
}
// DaemonAdapters is a set of methods that server as adapters to bridge the
@@ -597,8 +598,8 @@ func (s *StateMachine[Event, Env]) applyEvents(ctx context.Context,
}
s.log.InfoS(ctx, "State transition",
btclog.Fmt("from_state", "%T", currentState),
btclog.Fmt("to_state", "%T", transition.NextState))
btclog.Fmt("from_state", "%v", currentState),
btclog.Fmt("to_state", "%v", transition.NextState))
// With our events processed, we'll now update our
// internal state.