From b749aeeeedb46a9858afda2aff476325ace6aea7 Mon Sep 17 00:00:00 2001 From: DinhLN Date: Tue, 20 Nov 2018 15:13:28 +0700 Subject: [PATCH] Fixed gasprice minimum 2500 for get gasprice api. Remove check minimum gas price in tx pool. --- common/constants.go | 1 + common/types_test.go | 2 +- eth/gasprice/gasprice.go | 6 ++++++ params/version.go | 6 +++--- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/common/constants.go b/common/constants.go index a0a88f1255..0571a8cf11 100644 --- a/common/constants.go +++ b/common/constants.go @@ -14,4 +14,5 @@ const ( LimitPenaltyEpoch = 4 BlocksPerYear = uint64(15768000) LimitThresholdNonceInQueue = 10 + MinGasPrice = 2500 ) diff --git a/common/types_test.go b/common/types_test.go index e481db96c3..0bf9cb4ba9 100644 --- a/common/types_test.go +++ b/common/types_test.go @@ -151,7 +151,7 @@ func BenchmarkAddressHex(b *testing.B) { } func TestRemoveItemInArray(t *testing.T) { - array := []Address{HexToAddress("0x0000003"),HexToAddress("0x0000001"), HexToAddress("0x0000002"),HexToAddress("0x0000003")} + array := []Address{HexToAddress("0x0000003"), HexToAddress("0x0000001"), HexToAddress("0x0000002"), HexToAddress("0x0000003")} remove := []Address{HexToAddress("0x0000002"), HexToAddress("0x0000004"), HexToAddress("0x0000003")} array = RemoveItemFromArray(array, remove) if len(array) != 1 { diff --git a/eth/gasprice/gasprice.go b/eth/gasprice/gasprice.go index 54325692c6..0fe0f3c513 100644 --- a/eth/gasprice/gasprice.go +++ b/eth/gasprice/gasprice.go @@ -30,6 +30,7 @@ import ( ) var maxPrice = big.NewInt(500 * params.Shannon) +var minPrice = big.NewInt(common.MinGasPrice) type Config struct { Blocks int @@ -140,6 +141,11 @@ func (gpo *Oracle) SuggestPrice(ctx context.Context) (*big.Int, error) { price = new(big.Int).Set(maxPrice) } + // Check gas price min. + if price.Cmp(minPrice) < 0 { + price = new(big.Int).Set(minPrice) + } + gpo.cacheLock.Lock() gpo.lastHead = headHash gpo.lastPrice = price diff --git a/params/version.go b/params/version.go index e02ea62337..48f0dfb7b6 100644 --- a/params/version.go +++ b/params/version.go @@ -21,9 +21,9 @@ import ( ) const ( - VersionMajor = 0 // Major version component of the current release - VersionMinor = 3 // Minor version component of the current release - VersionPatch = 0 // Patch version component of the current release + VersionMajor = 0 // Major version component of the current release + VersionMinor = 3 // Minor version component of the current release + VersionPatch = 0 // Patch version component of the current release VersionMeta = "beta" // Version metadata to append to the version string )