From fa7ff32f355f428ab3115475062434654f8da6b1 Mon Sep 17 00:00:00 2001 From: Aaron Craelius Date: Fri, 13 Jan 2023 12:21:57 -0500 Subject: [PATCH] feat(core): add begin/end block extension interfaces (#14604) --- core/appmodule/module.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/core/appmodule/module.go b/core/appmodule/module.go index 2502d25c48..220dbb06fb 100644 --- a/core/appmodule/module.go +++ b/core/appmodule/module.go @@ -1,6 +1,8 @@ package appmodule import ( + "context" + "cosmossdk.io/depinject" "google.golang.org/grpc" ) @@ -35,3 +37,23 @@ type HasServices interface { // do not need to specify this in golang code. RegisterServices(grpc.ServiceRegistrar) } + +// HasBeginBlocker is the extension interface that modules should implement to run +// custom logic before transaction processing in a block. +type HasBeginBlocker interface { + AppModule + + // BeginBlock is a method that will be run before transactions are processed in + // a block. + BeginBlock(context.Context) error +} + +// HasEndBlocker is the extension interface that modules should implement to run +// custom logic after transaction processing in a block. +type HasEndBlocker interface { + AppModule + + // EndBlock is a method that will be run after transactions are processed in + // a block. + EndBlock(context.Context) error +}