diff --git a/server/start.go b/server/start.go index b5c00a6f0576..3e0c75906659 100644 --- a/server/start.go +++ b/server/start.go @@ -4,6 +4,9 @@ package server import ( "fmt" + "github.com/cosmos/cosmos-sdk/client/context" + "github.com/cosmos/cosmos-sdk/x/auth/types" + "github.com/tendermint/tendermint/rpc/client/local" "os" "runtime/pprof" @@ -275,6 +278,14 @@ func startInProcess(ctx *Context, cdc *codec.Codec, appCreator AppCreator, baseapp.SetGlobalMempool(tmNode.Mempool(), cfg.Mempool.SortTxByGp, cfg.Mempool.EnablePendingPool) + if cfg.Mempool.EnablePendingPool { + cliCtx := context.NewCLIContext().WithCodec(cdc) + cliCtx.Client = local.New(tmNode) + cliCtx.TrustNode = true + accRetriever := types.NewAccountRetriever(cliCtx) + tmNode.Mempool().SetAccountRetriever(accRetriever) + } + // run forever (the node will not be returned) select {} } diff --git a/x/auth/types/account_retriver_exchain.go b/x/auth/types/account_retriver_exchain.go new file mode 100644 index 000000000000..673eeb1543bf --- /dev/null +++ b/x/auth/types/account_retriver_exchain.go @@ -0,0 +1,15 @@ +package types + +import sdk "github.com/cosmos/cosmos-sdk/types" + +func (ar AccountRetriever) GetAccountNonce(address string) uint64 { + addr, err := sdk.AccAddressFromBech32(address) + if err != nil { + return 0 + } + acc, err := ar.GetAccount(addr) + if err != nil { + return 0 + } + return acc.GetSequence() +}