Skip to content

Commit

Permalink
chore: clean-up after go-plugin system pr
Browse files Browse the repository at this point in the history
  • Loading branch information
julienrbrt committed Mar 14, 2023
1 parent 825245d commit 317a521
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 14 deletions.
6 changes: 2 additions & 4 deletions baseapp/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ func (app *BaseApp) BeginBlock(req abci.RequestBeginBlock) (res abci.ResponseBeg
for _, abciListener := range app.streamingManager.ABCIListeners {
ctx := app.deliverState.ctx
blockHeight := ctx.BlockHeight()
if err := abciListener.ListenBeginBlock(app.deliverState.ctx, req, res); err != nil {
if err := abciListener.ListenBeginBlock(ctx, req, res); err != nil {
app.logger.Error("BeginBlock listening hook failed", "height", blockHeight, "err", err)
}
}
Expand Down Expand Up @@ -426,15 +426,13 @@ func (app *BaseApp) DeliverTx(req abci.RequestDeliverTx) abci.ResponseDeliverTx
return sdkerrors.ResponseDeliverTxWithEvents(err, gInfo.GasWanted, gInfo.GasUsed, sdk.MarkEventsToIndex(anteEvents, app.indexEvents), app.trace)
}

res = abci.ResponseDeliverTx{
return abci.ResponseDeliverTx{
GasWanted: int64(gInfo.GasWanted), // TODO: Should type accept unsigned ints?
GasUsed: int64(gInfo.GasUsed), // TODO: Should type accept unsigned ints?
Log: result.Log,
Data: result.Data,
Events: sdk.MarkEventsToIndex(result.Events, app.indexEvents),
}

return res
}

// Commit implements the ABCI interface. It will commit all state that exists in
Expand Down
11 changes: 5 additions & 6 deletions baseapp/streaming.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package baseapp

import (
"fmt"
"os"
"sort"
"strings"

Expand All @@ -23,7 +22,7 @@ const (
)

// RegisterStreamingServices registers streaming services with the BaseApp.
func (app *BaseApp) RegisterStreamingServices(appOpts servertypes.AppOptions, keys map[string]*storetypes.KVStoreKey) {
func (app *BaseApp) RegisterStreamingServices(appOpts servertypes.AppOptions, keys map[string]*storetypes.KVStoreKey) error {
// register streaming services
streamingCfg := cast.ToStringMap(appOpts.Get(StreamingTomlKey))
for service := range streamingCfg {
Expand All @@ -33,15 +32,15 @@ func (app *BaseApp) RegisterStreamingServices(appOpts servertypes.AppOptions, ke
logLevel := cast.ToString(appOpts.Get(flags.FlagLogLevel))
plugin, err := streaming.NewStreamingPlugin(pluginName, logLevel)
if err != nil {
app.logger.Error("failed to load streaming plugin", "error", err)
os.Exit(1)
return fmt.Errorf("failed to load streaming plugin: %w", err)
}
if err := app.registerStreamingPlugin(appOpts, keys, plugin); err != nil {
app.logger.Error("failed to register streaming plugin", "error", err)
os.Exit(1)
return fmt.Errorf("failed to register streaming plugin %w", err)
}
}
}

return nil
}

// registerStreamingPlugin registers streaming plugins with the BaseApp.
Expand Down
4 changes: 3 additions & 1 deletion simapp/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,9 @@ func NewSimApp(
)

// register streaming services
bApp.RegisterStreamingServices(appOpts, keys)
if err := bApp.RegisterStreamingServices(appOpts, keys); err != nil {
panic(err)
}

tkeys := storetypes.NewTransientStoreKeys(paramstypes.TStoreKey)
// NOTE: The testingkey is just mounted for testing purposes. Actual applications should
Expand Down
4 changes: 3 additions & 1 deletion simapp/app_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,9 @@ func NewSimApp(
app.App = appBuilder.Build(logger, db, traceStore, baseAppOptions...)

// register streaming services
app.RegisterStreamingServices(appOpts, app.kvStoreKeys())
if err := app.RegisterStreamingServices(appOpts, app.kvStoreKeys()); err != nil {
panic(err)
}

/**** Module Options ****/

Expand Down
4 changes: 2 additions & 2 deletions store/streaming/abci/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -302,10 +302,10 @@ func NewApp(...) *App {
logLevel := cast.ToString(appOpts.Get(flags.FlagLogLevel))
plugin, err := streaming.NewStreamingPlugin(pluginName, logLevel)
if err != nil {
tmos.Exit(err.Error())
cmtos.Exit(err.Error())
}
if err := baseapp.RegisterStreamingPlugin(bApp, appOpts, keys, plugin); err != nil {
tmos.Exit(err.Error())
cmtos.Exit(err.Error())
}
}
}
Expand Down

0 comments on commit 317a521

Please sign in to comment.