diff options
author | obscuren <geffobscura@gmail.com> | 2015-03-18 20:00:01 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2015-03-18 20:00:01 +0800 |
commit | 0a1eeca41e6ba5920ba65d9b41654768299bc7e3 (patch) | |
tree | 0c286872355608c317f9e0ec1897bb79386ae94f /miner | |
parent | 942980609fb8a36873689bd3bd0a15488f327d56 (diff) | |
download | go-tangerine-0a1eeca41e6ba5920ba65d9b41654768299bc7e3.tar.gz go-tangerine-0a1eeca41e6ba5920ba65d9b41654768299bc7e3.tar.zst go-tangerine-0a1eeca41e6ba5920ba65d9b41654768299bc7e3.zip |
conversions. -compilable-
Diffstat (limited to 'miner')
-rw-r--r-- | miner/miner.go | 3 | ||||
-rw-r--r-- | miner/worker.go | 27 |
2 files changed, 16 insertions, 14 deletions
diff --git a/miner/miner.go b/miner/miner.go index 7bf67a6ec..ccc19c754 100644 --- a/miner/miner.go +++ b/miner/miner.go @@ -4,6 +4,7 @@ import ( "math/big" "github.com/ethereum/ethash" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/logger" "github.com/ethereum/go-ethereum/pow" @@ -32,7 +33,7 @@ func (self *Miner) Mining() bool { return self.mining } -func (self *Miner) Start(coinbase []byte) { +func (self *Miner) Start(coinbase common.Address) { self.mining = true self.worker = newWorker(coinbase, self.eth) self.worker.register(NewCpuMiner(0, self.pow)) diff --git a/miner/worker.go b/miner/worker.go index 10fc6f508..63d1bfa0b 100644 --- a/miner/worker.go +++ b/miner/worker.go @@ -7,9 +7,9 @@ import ( "sync" "time" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core/types" - "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/event" "github.com/ethereum/go-ethereum/logger" "github.com/ethereum/go-ethereum/pow" @@ -39,7 +39,7 @@ func env(block *types.Block, eth core.Backend) *environment { coinbase: state.GetOrNewStateObject(block.Coinbase()), } for _, ancestor := range eth.ChainManager().GetAncestors(block, 7) { - env.ancestors.Add(string(ancestor.Hash())) + env.ancestors.Add(ancestor.Hash()) } return env @@ -71,14 +71,14 @@ type worker struct { eth core.Backend chain *core.ChainManager proc *core.BlockProcessor - coinbase []byte + coinbase common.Address current *environment mining bool } -func newWorker(coinbase []byte, eth core.Backend) *worker { +func newWorker(coinbase common.Address, eth core.Backend) *worker { return &worker{ eth: eth, mux: eth.EventMux(), @@ -152,13 +152,13 @@ func (self *worker) wait() { block := self.current.block if block.Number().Uint64() == work.Number && block.Nonce() == 0 { self.current.block.SetNonce(work.Nonce) - self.current.block.Header().MixDigest = work.MixDigest + self.current.block.Header().MixDigest = common.BytesToHash(work.MixDigest) jsonlogger.LogJson(&logger.EthMinerNewBlock{ - BlockHash: common.Bytes2Hex(block.Hash()), + BlockHash: block.Hash().Hex(), BlockNumber: block.Number(), - ChainHeadHash: common.Bytes2Hex(block.ParentHeaderHash), - BlockPrevHash: common.Bytes2Hex(block.ParentHeaderHash), + ChainHeadHash: block.ParentHeaderHash.Hex(), + BlockPrevHash: block.ParentHeaderHash.Hex(), }) if err := self.chain.InsertChain(types.Blocks{self.current.block}); err == nil { @@ -208,9 +208,10 @@ gasLimit: fallthrough case core.IsInvalidTxErr(err): // Remove invalid transactions - self.chain.TxState().RemoveNonce(tx.From(), tx.Nonce()) + from, _ := tx.From() + self.chain.TxState().RemoveNonce(from, tx.Nonce()) remove = append(remove, tx) - minerlogger.Infof("TX (%x) failed. Transaction will be removed\n", tx.Hash()[:4]) + minerlogger.Infof("TX (%x) failed. Transaction will be removed\n", tx.Hash().Bytes()[:4]) case state.IsGasLimitErr(err): minerlogger.Infof("Gas limit reached for block. %d TXs included in this block\n", i) // Break on gas limit @@ -232,13 +233,13 @@ var ( ) func (self *worker) commitUncle(uncle *types.Header) error { - if self.current.uncles.Has(string(uncle.Hash())) { + if self.current.uncles.Has(uncle.Hash()) { // Error not unique return core.UncleError("Uncle not unique") } - self.current.uncles.Add(string(uncle.Hash())) + self.current.uncles.Add(uncle.Hash()) - if !self.current.ancestors.Has(string(uncle.ParentHash)) { + if !self.current.ancestors.Has(uncle.ParentHash) { return core.UncleError(fmt.Sprintf("Uncle's parent unknown (%x)", uncle.ParentHash[0:4])) } |