Skip to content

Commit

Permalink
Merge PR: fix repair state (#1531)
Browse files Browse the repository at this point in the history
* fix tx_index DB type

* Update repair_state.go

Co-authored-by: xiangjianmeng <[email protected]>
Co-authored-by: KamiD <[email protected]>
Co-authored-by: Zhong Qiu <[email protected]>
  • Loading branch information
4 people authored Feb 7, 2022
1 parent 5dc17aa commit 4d7fa36
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions app/repair_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package app

import (
"fmt"
cfg "github.com/okex/exchain/libs/tendermint/config"
"io"
"io/ioutil"
"log"
Expand All @@ -15,26 +14,27 @@ import (
"github.com/okex/exchain/libs/cosmos-sdk/store/rootmulti"
sdk "github.com/okex/exchain/libs/cosmos-sdk/types"
"github.com/okex/exchain/libs/iavl"
cfg "github.com/okex/exchain/libs/tendermint/config"
"github.com/okex/exchain/libs/tendermint/global"
tmlog "github.com/okex/exchain/libs/tendermint/libs/log"
"github.com/okex/exchain/libs/tendermint/mock"
"github.com/okex/exchain/libs/tendermint/node"
tmnode "github.com/okex/exchain/libs/tendermint/node"
"github.com/okex/exchain/libs/tendermint/proxy"
sm "github.com/okex/exchain/libs/tendermint/state"
"github.com/okex/exchain/libs/tendermint/state/txindex"
"github.com/okex/exchain/libs/tendermint/state/txindex/kv"
"github.com/okex/exchain/libs/tendermint/state/txindex/null"
"github.com/okex/exchain/libs/tendermint/store"
"github.com/okex/exchain/libs/tendermint/types"
"github.com/spf13/viper"
dbm "github.com/okex/exchain/libs/tm-db"
"github.com/spf13/viper"
)

const (
applicationDB = "application"
blockStoreDB = "blockstore"
stateDB = "state"
txIndexDB = "tx_index"

FlagStartHeight string = "start-height"
FlagEnableRepairState string = "enable-repair-state"
Expand Down Expand Up @@ -155,7 +155,7 @@ func doRepair(ctx *server.Context, state sm.State, stateStoreDB dbm.DB,
var err error
// repair state
eventBus := types.NewEventBus()
err = startEventBusAndIndexerService(ctx.Config, tmnode.DefaultDBProvider, eventBus, ctx.Logger)
err = startEventBusAndIndexerService(ctx.Config, eventBus, ctx.Logger)
panicError(err)
blockExec := sm.NewBlockExecutor(stateStoreDB, ctx.Logger, proxyApp.Consensus(), mock.Mempool{}, sm.MockEvidencePool{})
blockExec.SetIsAsyncDeliverTx(viper.GetBool(sm.FlagParalleledTx))
Expand Down Expand Up @@ -184,8 +184,7 @@ func doRepair(ctx *server.Context, state sm.State, stateStoreDB dbm.DB,
}
}

func startEventBusAndIndexerService(config *cfg.Config, dbProvider tmnode.DBProvider,
eventBus *types.EventBus, logger tmlog.Logger) error {
func startEventBusAndIndexerService(config *cfg.Config, eventBus *types.EventBus, logger tmlog.Logger) error {
eventBus.SetLogger(logger.With("module", "events"))
if err := eventBus.Start(); err != nil {
return err
Expand All @@ -194,7 +193,7 @@ func startEventBusAndIndexerService(config *cfg.Config, dbProvider tmnode.DBProv
var txIndexer txindex.TxIndexer
switch config.TxIndex.Indexer {
case "kv":
store, err := dbProvider(&tmnode.DBContext{ID: "tx_index", Config: config})
store, err := openDB(txIndexDB, filepath.Join(config.RootDir, "data"))
if err != nil {
return err
}
Expand Down

0 comments on commit 4d7fa36

Please sign in to comment.