Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update indexer.go #137

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 36 additions & 42 deletions app/indexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,19 @@ func setupIndexer(
appOpts servertypes.AppOptions,
indexerDB, kvindexerDB dbm.DB,
) (evmindexer.EVMIndexer, *kvindexerkeeper.Keeper, *kvindexermodule.AppModuleBasic, *storetypes.StreamingManager, error) {
// setup evm indexer
// Initialize EVM Indexer
evmIndexer, err := evmindexer.NewEVMIndexer(indexerDB, app.appCodec, app.Logger(), app.txConfig, app.EVMKeeper)
if err != nil {
return nil, nil, nil, nil, err
}

// initialize the indexer keeper
// Configure kvindexer
kvindexerConfig, err := kvindexerconfig.NewConfig(appOpts)
if err != nil {
return nil, nil, nil, nil, err
}

// Initialize kvIndexerKeeper
kvIndexerKeeper := kvindexerkeeper.NewKeeper(
app.appCodec,
"evm",
Expand All @@ -45,65 +47,57 @@ func setupIndexer(
app.vc,
)

smBlock, err := blocksubmodule.NewBlockSubmodule(app.appCodec, kvIndexerKeeper, app.OPChildKeeper)
if err != nil {
return nil, nil, nil, nil, err
// Setup submodules
subModules := []interface {
Setup() error
}{
blocksubmodule.NewBlockSubmodule(app.appCodec, kvIndexerKeeper, app.OPChildKeeper),
tx.NewTxSubmodule(app.appCodec, kvIndexerKeeper),
pair.NewPairSubmodule(app.appCodec, kvIndexerKeeper, app.IBCKeeper.ChannelKeeper, app.TransferKeeper),
nft.NewEvmNFTSubmodule(app.ac, app.appCodec, kvIndexerKeeper, app.EVMKeeper, nil),
}
smTx, err := tx.NewTxSubmodule(app.appCodec, kvIndexerKeeper)
if err != nil {
return nil, nil, nil, nil, err

for _, subModule := range subModules {
if err := subModule.Setup(); err != nil {
return nil, nil, nil, nil, err
}
}
smPair, err := pair.NewPairSubmodule(app.appCodec, kvIndexerKeeper, app.IBCKeeper.ChannelKeeper, app.TransferKeeper)
if err != nil {

// Register submodules with kvIndexerKeeper
if err := kvIndexerKeeper.RegisterSubmodules(subModules...); err != nil {
return nil, nil, nil, nil, err
}
smNft, err := nft.NewEvmNFTSubmodule(app.ac, app.appCodec, kvIndexerKeeper, app.EVMKeeper, smPair)

// Create kvIndexer
kvIndexer, err := kvindexer.NewIndexer(app.GetBaseApp().Logger(), kvIndexerKeeper)
if err != nil {
return nil, nil, nil, nil, err
}
err = kvIndexerKeeper.RegisterSubmodules(smBlock, smTx, smPair, smNft)
if err != nil {

if err := kvIndexer.Validate(); err != nil {
return nil, nil, nil, nil, err
}

// Add your implementation here

kvIndexer, err := kvindexer.NewIndexer(app.GetBaseApp().Logger(), kvIndexerKeeper)
if err != nil {
if err := kvIndexer.Prepare(nil); err != nil {
return nil, nil, nil, nil, err
}

listeners := []storetypes.ABCIListener{evmIndexer}

var kvIndexerModule *kvindexermodule.AppModuleBasic
if kvIndexer != nil {
if err = kvIndexer.Validate(); err != nil {
return nil, nil, nil, nil, err
}

if err = kvIndexer.Prepare(nil); err != nil {
return nil, nil, nil, nil, err
}

if err = kvIndexerKeeper.Seal(); err != nil {
return nil, nil, nil, nil, err
}
if err := kvIndexerKeeper.Seal(); err != nil {
return nil, nil, nil, nil, err
}

if err = kvIndexer.Start(nil); err != nil {
return nil, nil, nil, nil, err
}
if err := kvIndexer.Start(nil); err != nil {
return nil, nil, nil, nil, err
}

listeners = append(listeners, kvIndexer)
listeners := []storetypes.ABCIListener{evmIndexer, kvIndexer}

// set kvindexer module
m := kvindexermodule.NewAppModuleBasic(kvIndexerKeeper)
kvIndexerModule = &m
}
kvIndexerModule := kvindexermodule.NewAppModuleBasic(kvIndexerKeeper)

streamingManager := storetypes.StreamingManager{
streamingManager := &storetypes.StreamingManager{
ABCIListeners: listeners,
StopNodeOnErr: true,
}

return evmIndexer, kvIndexerKeeper, kvIndexerModule, &streamingManager, nil
return evmIndexer, kvIndexerKeeper, &kvIndexerModule, streamingManager, nil
}