Skip to content
This repository has been archived by the owner on Dec 21, 2022. It is now read-only.

Commit

Permalink
Merge PR: add AccountNonce for pending pool (#153)
Browse files Browse the repository at this point in the history
  • Loading branch information
ilovers authored Sep 6, 2021
1 parent 2e650e2 commit ea9c2e5
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
11 changes: 11 additions & 0 deletions server/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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 {}
}
15 changes: 15 additions & 0 deletions x/auth/types/account_retriver_exchain.go
Original file line number Diff line number Diff line change
@@ -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()
}

0 comments on commit ea9c2e5

Please sign in to comment.