mirror of
https://github.com/0glabs/0g-chain.git
synced 2025-04-01 14:26:02 +00:00
add account nonce operator to rewind account nonce if tx removed by full of mempool
This commit is contained in:
parent
248db0f47c
commit
08000544c9
28
app/app.go
28
app/app.go
@ -1068,3 +1068,31 @@ func GetMaccPerms() map[string][]string {
|
||||
}
|
||||
return perms
|
||||
}
|
||||
|
||||
type accountNonceOp struct {
|
||||
ak evmtypes.AccountKeeper
|
||||
}
|
||||
|
||||
type AccountNonceOp interface {
|
||||
GetAccountNonce(ctx sdk.Context, address string) uint64
|
||||
SetAccountNonce(ctx sdk.Context, address string, nonce uint64)
|
||||
}
|
||||
|
||||
func NewAccountNonceOp(app *App) AccountNonceOp {
|
||||
return &accountNonceOp{
|
||||
ak: app.accountKeeper,
|
||||
}
|
||||
}
|
||||
|
||||
func (ano *accountNonceOp) GetAccountNonce(ctx sdk.Context, address string) uint64 {
|
||||
bzAcc, _ := sdk.AccAddressFromBech32(address)
|
||||
acc := ano.ak.GetAccount(ctx, bzAcc)
|
||||
return acc.GetSequence()
|
||||
}
|
||||
|
||||
func (ano *accountNonceOp) SetAccountNonce(ctx sdk.Context, address string, nonce uint64) {
|
||||
bzAcc, _ := sdk.AccAddressFromBech32(address)
|
||||
acc := ano.ak.GetAccount(ctx, bzAcc)
|
||||
acc.SetSequence(nonce)
|
||||
ano.ak.SetAccount(ctx, acc)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user