diff --git a/core/blockchain.go b/core/blockchain.go index 6f1cdf3208..5c9a229937 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -57,8 +57,8 @@ var ( ) const ( - bodyCacheLimit = 256 - blockCacheLimit = 256 + bodyCacheLimit = 2560 + blockCacheLimit = 2560 maxFutureBlocks = 256 maxTimeFutureBlocks = 30 badBlockLimit = 10 diff --git a/eth/api_backend.go b/eth/api_backend.go index 499653d1c6..856b5c62a6 100644 --- a/eth/api_backend.go +++ b/eth/api_backend.go @@ -18,8 +18,11 @@ package eth import ( "context" + "encoding/json" "github.com/ethereum/go-ethereum/consensus/XDPoS" + "io/ioutil" "math/big" + "path/filepath" "github.com/ethereum/go-ethereum/accounts" "github.com/ethereum/go-ethereum/common" @@ -241,6 +244,18 @@ func (s *EthApiBackend) GetRewardByHash(hash common.Hash) map[string]interface{} if rewards != nil { return rewards } + } else { + header := s.eth.blockchain.GetHeaderByHash(hash) + if header != nil { + data, err := ioutil.ReadFile(filepath.Join(s.eth.config.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 + } + } + } } return make(map[string]interface{}) } \ No newline at end of file diff --git a/miner/worker.go b/miner/worker.go index b626805043..9e5fb6ef54 100644 --- a/miner/worker.go +++ b/miner/worker.go @@ -613,12 +613,13 @@ func (self *worker) commitNewWork() { delete(self.possibleUncles, hash) } } - // Create the new block to seal with the consensus engine - if work.Block, err = self.engine.Finalize(self.chain, header, work.state, work.txs, uncles, work.receipts); err != nil { - log.Error("Failed to finalize block for sealing", "err", err) - return - } - if atomic.LoadInt32(&self.mining) == 1 { + if atomic.LoadInt32(&self.mining) == 1 { + // Create the new block to seal with the consensus engine + if work.Block, err = self.engine.Finalize(self.chain, header, work.state, work.txs, uncles, work.receipts); err != nil { + log.Error("Failed to finalize block for sealing", "err", err) + return + } + } log.Info("Committing new block", "number", work.Block.Number(), "txs", work.tcount, "special txs", len(specialTxs), "uncles", len(uncles), "elapsed", common.PrettyDuration(time.Since(tstart))) self.unconfirmed.Shift(work.Block.NumberU64() - 1) self.lastParentBlockCommit = parent.Hash().Hex()