mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-08-26 21:51:27 +02:00
protofsm: add String() method to ProtocolState
This commit is contained in:
@@ -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.
|
||||
|
@@ -51,6 +51,10 @@ type dummyStateStart struct {
|
||||
canSend *atomic.Bool
|
||||
}
|
||||
|
||||
func (d *dummyStateStart) String() string {
|
||||
return "dummyStateStart"
|
||||
}
|
||||
|
||||
var (
|
||||
hexDecode = func(keyStr string) []byte {
|
||||
keyBytes, _ := hex.DecodeString(keyStr)
|
||||
@@ -134,6 +138,10 @@ func (d *dummyStateStart) IsTerminal() bool {
|
||||
type dummyStateFin struct {
|
||||
}
|
||||
|
||||
func (d *dummyStateFin) String() string {
|
||||
return "dummyStateFin"
|
||||
}
|
||||
|
||||
func (d *dummyStateFin) ProcessEvent(event dummyEvents, env *dummyEnv,
|
||||
) (*StateTransition[dummyEvents, *dummyEnv], error) {
|
||||
|
||||
|
Reference in New Issue
Block a user