Skip to content

Commit

Permalink
go/consensus/tendermint: Add MessageRuntimeResumed message
Browse files Browse the repository at this point in the history
  • Loading branch information
kostko committed Dec 2, 2020
1 parent 74676d2 commit 443b4f5
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
7 changes: 6 additions & 1 deletion go/consensus/tendermint/apps/registry/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,13 @@ var (
MessageNewRuntimeRegistered = messageKind(0)

// MessageRuntimeUpdated is the message kind for runtime registration updates. The message is
// the runtime descriptor of the runtime that has been updated.
// the runtime descriptor of the runtime that has been updated. Any errors returned from the
// handler will prevent the runtime update from taking place.
//
// The message is also emitted for new runtime registrations.
MessageRuntimeUpdated = messageKind(1)

// MessageRuntimeResumed is the message kind for suspended runtime resumptions. The message is
// the runtime descriptor of the runtime that has been resumed.
MessageRuntimeResumed = messageKind(2)
)
6 changes: 3 additions & 3 deletions go/consensus/tendermint/apps/registry/transactions.go
Original file line number Diff line number Diff line change
Expand Up @@ -399,9 +399,9 @@ func (app *registryApplication) registerNode( // nolint: gocyclo
"runtime_id", rt.ID,
)

// Notify other interested applications about the new runtime.
if err = app.md.Publish(ctx, registryApi.MessageNewRuntimeRegistered, rt); err != nil {
ctx.Logger().Error("RegisterNode: failed to dispatch runtime registration message",
// Notify other interested applications about the resumed runtime.
if err = app.md.Publish(ctx, registryApi.MessageRuntimeResumed, rt); err != nil {
ctx.Logger().Error("RegisterNode: failed to dispatch runtime resumption message",
"err", err,
)
return err
Expand Down
4 changes: 4 additions & 0 deletions go/consensus/tendermint/apps/roothash/roothash.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ func (app *rootHashApplication) OnRegister(state tmapi.ApplicationState, md tmap
// Subscribe to messages emitted by other apps.
md.Subscribe(registryApi.MessageNewRuntimeRegistered, app)
md.Subscribe(registryApi.MessageRuntimeUpdated, app)
md.Subscribe(registryApi.MessageRuntimeResumed, app)
md.Subscribe(roothashApi.RuntimeMessageNoop, app)
}

Expand Down Expand Up @@ -292,6 +293,9 @@ func (app *rootHashApplication) ExecuteMessage(ctx *tmapi.Context, kind, msg int
return nil
}
return app.verifyRuntimeUpdate(ctx, msg.(*registry.Runtime))
case registryApi.MessageRuntimeResumed:
// A previously suspended runtime has been resumed.
return nil
case roothashApi.RuntimeMessageNoop:
// Noop message always succeeds.
return nil
Expand Down

0 comments on commit 443b4f5

Please sign in to comment.