Skip to content

Commit

Permalink
Support genesis and endblock hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
charithabandi committed Dec 13, 2024
1 parent 986beb2 commit c397c64
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
File renamed without changes.
23 changes: 12 additions & 11 deletions node/txapp/txapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"github.com/kwilteam/kwil-db/core/log"
"github.com/kwilteam/kwil-db/core/types"
"github.com/kwilteam/kwil-db/core/utils/order"
"github.com/kwilteam/kwil-db/extensions/hooks"
"github.com/kwilteam/kwil-db/extensions/resolutions"
"github.com/kwilteam/kwil-db/node/accounts"
"github.com/kwilteam/kwil-db/node/types/sql"
Expand Down Expand Up @@ -83,7 +84,7 @@ func NewTxApp(ctx context.Context, db sql.Executor, engine common.Engine, signer
// It can assign the initial validator set and initial account balances.
// It is only called once for a new chain.
func (r *TxApp) GenesisInit(ctx context.Context, db sql.DB, validators []*types.Validator, genesisAccounts []*types.Account,
initialHeight int64, chain *common.ChainContext) error {
initialHeight int64, chainCtx *common.ChainContext) error {

// Add Genesis Validators
for _, validator := range validators {
Expand All @@ -102,16 +103,16 @@ func (r *TxApp) GenesisInit(ctx context.Context, db sql.DB, validators []*types.
}

// genesis hooks
// for _, hook := range hooks.ListGenesisHooks() {
// err := hook.Hook(ctx, &types.App{
// Service: r.service.NamedLogger(hook.Name),
// DB: db,
// Engine: r.Engine,
// }, chain)
// if err != nil {
// return fmt.Errorf("error running genesis hook: %w", err)
// }
// }
for _, hook := range hooks.ListGenesisHooks() {
err := hook.Hook(ctx, &common.App{
Service: r.service.NamedLogger(hook.Name),
DB: db,
Engine: r.Engine,
}, chainCtx)
if err != nil {
return fmt.Errorf("error running genesis hook %s: %w", hook.Name, err)
}
}

return nil
}
Expand Down

0 comments on commit c397c64

Please sign in to comment.