|
|
@ -2,6 +2,7 @@ package ethminer |
|
|
|
|
|
|
|
|
|
|
|
import ( |
|
|
|
import ( |
|
|
|
"bytes" |
|
|
|
"bytes" |
|
|
|
|
|
|
|
"fmt" |
|
|
|
"github.com/ethereum/eth-go/ethchain" |
|
|
|
"github.com/ethereum/eth-go/ethchain" |
|
|
|
"github.com/ethereum/eth-go/ethutil" |
|
|
|
"github.com/ethereum/eth-go/ethutil" |
|
|
|
"github.com/ethereum/eth-go/ethwire" |
|
|
|
"github.com/ethereum/eth-go/ethwire" |
|
|
@ -61,10 +62,10 @@ func (miner *Miner) listener() { |
|
|
|
select { |
|
|
|
select { |
|
|
|
case chanMessage := <-miner.reactChan: |
|
|
|
case chanMessage := <-miner.reactChan: |
|
|
|
if block, ok := chanMessage.Resource.(*ethchain.Block); ok { |
|
|
|
if block, ok := chanMessage.Resource.(*ethchain.Block); ok { |
|
|
|
//log.Println("[MINER] Got new block via Reactor")
|
|
|
|
log.Println("[MINER] Got new block via Reactor") |
|
|
|
if bytes.Compare(miner.ethereum.BlockChain().CurrentBlock.Hash(), block.Hash()) == 0 { |
|
|
|
if bytes.Compare(miner.ethereum.BlockChain().CurrentBlock.Hash(), block.Hash()) == 0 { |
|
|
|
// TODO: Perhaps continue mining to get some uncle rewards
|
|
|
|
// TODO: Perhaps continue mining to get some uncle rewards
|
|
|
|
//log.Println("[MINER] New top block found resetting state")
|
|
|
|
log.Println("[MINER] New top block found resetting state") |
|
|
|
|
|
|
|
|
|
|
|
// Filter out which Transactions we have that were not in this block
|
|
|
|
// Filter out which Transactions we have that were not in this block
|
|
|
|
var newtxs []*ethchain.Transaction |
|
|
|
var newtxs []*ethchain.Transaction |
|
|
@ -86,7 +87,7 @@ func (miner *Miner) listener() { |
|
|
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
if bytes.Compare(block.PrevHash, miner.ethereum.BlockChain().CurrentBlock.PrevHash) == 0 { |
|
|
|
if bytes.Compare(block.PrevHash, miner.ethereum.BlockChain().CurrentBlock.PrevHash) == 0 { |
|
|
|
//log.Println("[MINER] Adding uncle block")
|
|
|
|
log.Println("[MINER] Adding uncle block") |
|
|
|
miner.uncles = append(miner.uncles, block) |
|
|
|
miner.uncles = append(miner.uncles, block) |
|
|
|
miner.ethereum.StateManager().Prepare(miner.block.State(), miner.block.State()) |
|
|
|
miner.ethereum.StateManager().Prepare(miner.block.State(), miner.block.State()) |
|
|
|
} |
|
|
|
} |
|
|
@ -133,8 +134,9 @@ func (miner *Miner) listener() { |
|
|
|
miner.ethereum.StateManager().PrepareDefault(miner.block) |
|
|
|
miner.ethereum.StateManager().PrepareDefault(miner.block) |
|
|
|
err := miner.ethereum.StateManager().ProcessBlock(miner.block, true) |
|
|
|
err := miner.ethereum.StateManager().ProcessBlock(miner.block, true) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
log.Println("Error result from process block:", err) |
|
|
|
log.Println(err) |
|
|
|
miner.block.State().Reset() |
|
|
|
miner.txs = []*ethchain.Transaction{} // Move this somewhere neat
|
|
|
|
|
|
|
|
miner.block = miner.ethereum.BlockChain().NewBlock(miner.coinbase, miner.txs) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
|
|
|
|
|
|
|
|
/* |
|
|
|
/* |
|
|
|