diff options
Diffstat (limited to 'miner/miner.go')
-rw-r--r-- | miner/miner.go | 27 |
1 files changed, 10 insertions, 17 deletions
diff --git a/miner/miner.go b/miner/miner.go index 795385424..589144c0c 100644 --- a/miner/miner.go +++ b/miner/miner.go @@ -29,10 +29,9 @@ import ( "github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum/ethutil" - "github.com/ethereum/go-ethereum/state" - "github.com/ethereum/go-ethereum/chain" - "github.com/ethereum/go-ethereum/chain/types" + "github.com/ethereum/go-ethereum/core" + "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/event" "github.com/ethereum/go-ethereum/logger" "github.com/ethereum/go-ethereum/wire" @@ -60,7 +59,7 @@ type Miner struct { localTxs map[int]*LocalTx localTxId int - pow chain.PoW + pow core.PoW quitCh chan struct{} powQuitCh chan struct{} @@ -75,7 +74,7 @@ func New(coinbase []byte, eth *eth.Ethereum) *Miner { return &Miner{ eth: eth, powQuitCh: make(chan struct{}), - pow: &chain.EasyPow{}, + pow: &core.EasyPow{}, mining: false, localTxs: make(map[int]*LocalTx), MinAcceptedGasPrice: big.NewInt(10000000000000), @@ -83,7 +82,7 @@ func New(coinbase []byte, eth *eth.Ethereum) *Miner { } } -func (self *Miner) GetPow() chain.PoW { +func (self *Miner) GetPow() core.PoW { return self.pow } @@ -117,7 +116,7 @@ func (self *Miner) Start() { self.powQuitCh = make(chan struct{}) mux := self.eth.EventMux() - self.events = mux.Subscribe(chain.NewBlockEvent{}, chain.TxPreEvent{}, &LocalTx{}) + self.events = mux.Subscribe(core.NewBlockEvent{}, core.TxPreEvent{}, &LocalTx{}) go self.update() go self.mine() @@ -148,7 +147,7 @@ out: select { case event := <-self.events.Chan(): switch event := event.(type) { - case chain.NewBlockEvent: + case core.NewBlockEvent: block := event.Block if self.eth.ChainManager().HasBlock(block.Hash()) { self.reset() @@ -157,7 +156,7 @@ out: } else if true { // do uncle stuff } - case chain.TxPreEvent, *LocalTx: + case core.TxPreEvent, *LocalTx: self.reset() go self.mine() } @@ -179,7 +178,6 @@ func (self *Miner) mine() { chainMan = self.eth.ChainManager() block = chainMan.NewBlock(self.Coinbase) ) - block.MinGasPrice = self.MinAcceptedGasPrice // Apply uncles if len(self.uncles) > 0 { @@ -206,7 +204,7 @@ func (self *Miner) mine() { // Accumulate the rewards included for this block blockManager.AccumelateRewards(block.State(), block, parent) - block.State().Update() + block.State().Update(ethutil.Big0) minerlogger.Infof("Mining on block. Includes %v transactions", len(transactions)) @@ -214,15 +212,10 @@ func (self *Miner) mine() { nonce := self.pow.Search(block, self.powQuitCh) if nonce != nil { block.Nonce = nonce - lchain := chain.NewChain(types.Blocks{block}) - _, err := chainMan.TestChain(lchain) + err := chainMan.InsertChain(types.Blocks{block}) if err != nil { minerlogger.Infoln(err) } else { - chainMan.InsertChain(lchain, func(block *types.Block, _ state.Messages) { - self.eth.EventMux().Post(chain.NewBlockEvent{block}) - }) - self.eth.Broadcast(wire.MsgBlockTy, []interface{}{block.Value().Val}) minerlogger.Infof("🔨 Mined block %x\n", block.Hash()) |