Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
facundomedica committed Dec 19, 2024
1 parent f620313 commit ca5d8f4
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions runtime/v2/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ type AppBuilder[T transaction.Tx] struct {
branch func(state store.ReaderMap) store.WriterMap
txValidator func(ctx context.Context, tx T) error
postTxExec func(ctx context.Context, tx T, success bool) error
preblocker func(ctx context.Context, txs []T, mmPreblocker func()) error
preblocker func(ctx context.Context, txs []T, mmPreblocker func() error) error
}

// RegisterModules registers the provided modules with the module manager.
Expand Down Expand Up @@ -98,19 +98,13 @@ func (a *AppBuilder[T]) Build(opts ...AppBuilderOption[T]) (*App[T], error) {

preblockerFn := func(ctx context.Context, txs []T) error {
if a.preblocker != nil {
return a.preblocker(ctx, txs, func() {
if err := a.app.moduleManager.PreBlocker()(ctx, txs); err != nil {
panic(err)
}
return a.preblocker(ctx, txs, func() error {
return a.app.moduleManager.PreBlocker()(ctx, txs)
})
} else {
// if there is no preblocker set, call the module manager's preblocker directly
if err := a.app.moduleManager.PreBlocker()(ctx, txs); err != nil {
return err
}
}

return nil
// if there is no preblocker set, call the module manager's preblocker directly
return a.app.moduleManager.PreBlocker()(ctx, txs)
}

stf, err := stf.New[T](
Expand Down Expand Up @@ -244,7 +238,7 @@ func AppBuilderWithPostTxExec[T transaction.Tx](
// This is especially useful when implementing vote extensions.
func AppBuilderWithPreblocker[T transaction.Tx](
preblocker func(
ctx context.Context, txs []T, mmPreblocker func(),
ctx context.Context, txs []T, mmPreblocker func() error,
) error,
) AppBuilderOption[T] {
return func(a *AppBuilder[T]) {
Expand Down

0 comments on commit ca5d8f4

Please sign in to comment.