From 443b4f53ec0fbce5dd18de202571e9e9606ac080 Mon Sep 17 00:00:00 2001 From: Jernej Kos Date: Wed, 2 Dec 2020 10:47:32 +0100 Subject: [PATCH] go/consensus/tendermint: Add MessageRuntimeResumed message --- go/consensus/tendermint/apps/registry/api/api.go | 7 ++++++- go/consensus/tendermint/apps/registry/transactions.go | 6 +++--- go/consensus/tendermint/apps/roothash/roothash.go | 4 ++++ 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/go/consensus/tendermint/apps/registry/api/api.go b/go/consensus/tendermint/apps/registry/api/api.go index acb84b03a4a..7932e194164 100644 --- a/go/consensus/tendermint/apps/registry/api/api.go +++ b/go/consensus/tendermint/apps/registry/api/api.go @@ -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) ) diff --git a/go/consensus/tendermint/apps/registry/transactions.go b/go/consensus/tendermint/apps/registry/transactions.go index aac5d3681ad..0e342448e49 100644 --- a/go/consensus/tendermint/apps/registry/transactions.go +++ b/go/consensus/tendermint/apps/registry/transactions.go @@ -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 diff --git a/go/consensus/tendermint/apps/roothash/roothash.go b/go/consensus/tendermint/apps/roothash/roothash.go index 7aaeecbdbb7..08ce679ccb3 100644 --- a/go/consensus/tendermint/apps/roothash/roothash.go +++ b/go/consensus/tendermint/apps/roothash/roothash.go @@ -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) } @@ -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