diff --git a/eth/api_backend.go b/eth/api_backend.go index 24c78048c3..97dfea2873 100644 --- a/eth/api_backend.go +++ b/eth/api_backend.go @@ -18,8 +18,10 @@ package eth import ( "context" - "github.com/ethereum/go-ethereum/consensus/XDPoS" + "encoding/json" + "io/ioutil" "math/big" + "path/filepath" "github.com/ethereum/go-ethereum/accounts" "github.com/ethereum/go-ethereum/common" @@ -236,10 +238,24 @@ func (b *EthApiBackend) GetEngine() consensus.Engine { } func (s *EthApiBackend) GetRewardByHash(hash common.Hash) map[string]interface{} { - if c, ok := s.eth.Engine().(*XDPoS.XDPoS); ok { - rewards := c.GetRewards(hash) - if rewards != nil { - return rewards + header := s.eth.blockchain.GetHeaderByHash(hash) + if header != nil { + data, err := ioutil.ReadFile(filepath.Join(common.StoreRewardFolder, header.Number.String()+"."+header.Hash().Hex())) + if err == nil { + rewards := make(map[string]interface{}) + err = json.Unmarshal(data, &rewards) + if err == nil { + return rewards + } + } else { + data, err = ioutil.ReadFile(filepath.Join(common.StoreRewardFolder, header.Number.String()+"."+header.HashNoValidator().Hex())) + if err == nil { + rewards := make(map[string]interface{}) + err = json.Unmarshal(data, &rewards) + if err == nil { + return rewards + } + } } } return make(map[string]interface{}) diff --git a/eth/config.go b/eth/config.go index 6f0d58955e..dbfe973913 100644 --- a/eth/config.go +++ b/eth/config.go @@ -114,8 +114,6 @@ type Config struct { // Miscellaneous options DocRoot string `toml:"-"` - - StoreRewardFolder string } type configMarshaling struct { diff --git a/eth/downloader/.goutputstream-OL09XZ b/eth/downloader/.goutputstream-OL09XZ deleted file mode 100644 index d4eb337946..0000000000 --- a/eth/downloader/.goutputstream-OL09XZ +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright 2015 The go-ethereum Authors -// This file is part of the go-ethereum library. -// -// The go-ethereum library is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// The go-ethereum library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with the go-ethereum library. If not, see . - -// Contains the metrics collected by the downloader. - -package downloader - -import ( - "github.com/ethereum/go-ethereum/metrics" -) - -var ( - headerInMeter = metrics.NewRegisteredMeter("eth/downloader/headers/in", nil) - headerReqTimer = metrics.NewRegisteredTimer("eth/downloader/headers/req", nil) - headerDropMeter = metrics.NewRegisteredMeter("eth/downloader/headers/drop", nil) - headerTimeoutMeter = metrics.NewRegisteredMeter("eth/downloader/headers/timeout", nil) - - bodyInMeter = metrics.NewRegisteredMeter("eth/downloader/bodies/in", nil) - bodyReqTimer = metrics.NewRegisteredTimer("eth/downloader/bodies/req", nil) - bodyDropMeter = metrics.NewRegisteredMeter("eth/downloader/bodies/drop", nil) - bodyTimeoutMeter = metrics.NewRegisteredMeter("eth/downloader/bodies/timeout", nil) - - receiptInMeter = metrics.NewRegisteredMeter("eth/downloader/receipts/in", nil) - receiptReqTimer = metrics.NewRegisteredTimer("eth/downloader/receipts/req", nil) - receiptDropMeter = metrics.NewRegisteredMeter("eth/downloader/receipts/drop", nil) - receiptTimeoutMeter = metrics.NewRegisteredMeter("eth/downloader/receipts/timeout", nil) - - stateInMeter = metrics.NewRegisteredMeter("eth/downloader/states/in", nil) - stateDropMeter = metrics.NewRegisteredMeter("eth/downloader/states/drop", nil) -) diff --git a/eth/gasprice/gasprice.go b/eth/gasprice/gasprice.go index 0fe0f3c513..f29d5a31c9 100644 --- a/eth/gasprice/gasprice.go +++ b/eth/gasprice/gasprice.go @@ -30,7 +30,6 @@ import ( ) var maxPrice = big.NewInt(500 * params.Shannon) -var minPrice = big.NewInt(common.MinGasPrice) type Config struct { Blocks int @@ -142,8 +141,9 @@ func (gpo *Oracle) SuggestPrice(ctx context.Context) (*big.Int, error) { } // Check gas price min. - if price.Cmp(minPrice) < 0 { - price = new(big.Int).Set(minPrice) + minGasPrice := big.NewInt(common.MinGasPrice) + if price.Cmp(minGasPrice) < 0 { + price = new(big.Int).Set(minGasPrice) } gpo.cacheLock.Lock()