Skip to content

Commit

Permalink
Merge PR: fix out of range, change "i++" and "err" (#952)
Browse files Browse the repository at this point in the history
* add defer unlock

* fix defer unlock

* fix defer unlock

* fix out of range[]

* add judge of i

Co-authored-by: MengXiangJian <[email protected]>
  • Loading branch information
chengzhinei and xiangjianmeng authored Aug 9, 2021
1 parent dcb54c2 commit 35f7b8f
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion app/rpc/namespaces/eth/tx_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,17 +223,26 @@ func (pool *TxPool) continueBroadcast(api *PublicEthereumAPI, currentNonce uint6
}
if err != nil {
if !strings.Contains(err.Error(), sdkerrors.ErrMempoolIsFull.Error()) {
i++
if i >= txsLen {
return fmt.Errorf("index out of range")
}
err = fmt.Errorf("%s, nonce %d of tx has been dropped, please send again",
err.Error(), pool.addressTxsPool[address][i].Data.AccountNonce)
i++
} else {
if i >= txsLen {
return fmt.Errorf("index out of range")
}
err = fmt.Errorf("%s, nonce %d :", err.Error(), pool.addressTxsPool[address][i].Data.AccountNonce)
}
api.logger.Error(err.Error())
}

// update txPool
if i != 0 {
if i > txsLen {
return fmt.Errorf("index out of range")
}
tmp := make([]*evmtypes.MsgEthereumTx, len(pool.addressTxsPool[address][i:]), viper.GetUint64(TxPoolSliceMaxLen))
copy(tmp, pool.addressTxsPool[address][i:])
pool.addressTxsPool[address] = tmp
Expand Down

0 comments on commit 35f7b8f

Please sign in to comment.