Skip to content

Commit

Permalink
Merge pull request #64 from usechain/test_patch7_zhouke
Browse files Browse the repository at this point in the history
make sure use.gasPrice's return is more than DefaultTxPoolConfig.Pric…
  • Loading branch information
lyszhang authored Mar 22, 2019
2 parents 27e99dc + 6dcd951 commit b1ef7b3
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions eth/gasprice/gasprice.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"sync"

"github.com/usechain/go-usechain/common"
"github.com/usechain/go-usechain/core"
"github.com/usechain/go-usechain/core/types"
"github.com/usechain/go-usechain/internal/ethapi"
"github.com/usechain/go-usechain/params"
Expand Down Expand Up @@ -80,6 +81,10 @@ func (gpo *Oracle) SuggestPrice(ctx context.Context) (*big.Int, error) {
lastPrice := gpo.lastPrice
gpo.cacheLock.RUnlock()

if lastPrice.Int64() < int64(core.DefaultTxPoolConfig.PriceLimit) {
lastPrice = big.NewInt(int64(core.DefaultTxPoolConfig.PriceLimit))
}

head, _ := gpo.backend.HeaderByNumber(ctx, rpc.LatestBlockNumber)
headHash := head.Hash()
if headHash == lastHead {
Expand Down Expand Up @@ -144,6 +149,9 @@ func (gpo *Oracle) SuggestPrice(ctx context.Context) (*big.Int, error) {
gpo.lastHead = headHash
gpo.lastPrice = price
gpo.cacheLock.Unlock()
if price.Int64() < int64(core.DefaultTxPoolConfig.PriceLimit) {
price = big.NewInt(int64(core.DefaultTxPoolConfig.PriceLimit))
}
return price, nil
}

Expand Down

0 comments on commit b1ef7b3

Please sign in to comment.