aboutsummaryrefslogtreecommitdiffstats
path: root/ethminer
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-05-17 20:07:52 +0800
committerobscuren <geffobscura@gmail.com>2014-05-17 20:07:52 +0800
commit8730dfdcc2e2b40410a57385e4864d15f2f0336b (patch)
treeeabf6400bc78b1796317fbb7cef642a7f2da2306 /ethminer
parent88686cbed27ad2e7d5c111051e06c270b1b352a3 (diff)
downloaddexon-8730dfdcc2e2b40410a57385e4864d15f2f0336b.tar
dexon-8730dfdcc2e2b40410a57385e4864d15f2f0336b.tar.gz
dexon-8730dfdcc2e2b40410a57385e4864d15f2f0336b.tar.bz2
dexon-8730dfdcc2e2b40410a57385e4864d15f2f0336b.tar.lz
dexon-8730dfdcc2e2b40410a57385e4864d15f2f0336b.tar.xz
dexon-8730dfdcc2e2b40410a57385e4864d15f2f0336b.tar.zst
dexon-8730dfdcc2e2b40410a57385e4864d15f2f0336b.zip
Changed how changes are being applied to states
Diffstat (limited to 'ethminer')
-rw-r--r--ethminer/miner.go24
1 files changed, 6 insertions, 18 deletions
diff --git a/ethminer/miner.go b/ethminer/miner.go
index bc29b2588..233a8bc32 100644
--- a/ethminer/miner.go
+++ b/ethminer/miner.go
@@ -53,8 +53,8 @@ func NewDefaultMiner(coinbase []byte, ethereum ethchain.EthManager) Miner {
}
func (miner *Miner) Start() {
// Prepare inital block
- miner.ethereum.StateManager().Prepare(miner.block.State(), miner.block.State())
- go func() { miner.listener() }()
+ //miner.ethereum.StateManager().Prepare(miner.block.State(), miner.block.State())
+ go miner.listener()
}
func (miner *Miner) listener() {
for {
@@ -88,7 +88,7 @@ func (miner *Miner) listener() {
if bytes.Compare(block.PrevHash, miner.ethereum.BlockChain().CurrentBlock.PrevHash) == 0 {
log.Println("[MINER] Adding uncle 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())
}
}
}
@@ -119,31 +119,19 @@ func (miner *Miner) listener() {
miner.block.SetUncles(miner.uncles)
}
- // FIXME @ maranh, first block doesn't need this. Everything after the first block does.
- // Please check and fix
- miner.ethereum.StateManager().Prepare(miner.block.State(), miner.block.State())
// Apply all transactions to the block
- miner.ethereum.StateManager().ApplyTransactions(miner.block, miner.block.Transactions())
- miner.ethereum.StateManager().AccumelateRewards(miner.block)
+ miner.ethereum.StateManager().ApplyTransactions(miner.block.State(), miner.block, miner.block.Transactions())
+ miner.ethereum.StateManager().AccumelateRewards(miner.block.State(), miner.block)
// Search the nonce
- //log.Println("[MINER] Initialision complete, starting mining")
miner.block.Nonce = miner.pow.Search(miner.block, miner.quitChan)
if miner.block.Nonce != nil {
- miner.ethereum.StateManager().PrepareDefault(miner.block)
- err := miner.ethereum.StateManager().ProcessBlock(miner.block, true)
+ err := miner.ethereum.StateManager().ProcessBlock(miner.ethereum.StateManager().CurrentState(), miner.block, true)
if err != nil {
log.Println(err)
miner.txs = []*ethchain.Transaction{} // Move this somewhere neat
miner.block = miner.ethereum.BlockChain().NewBlock(miner.coinbase, miner.txs)
} else {
-
- /*
- // XXX @maranh This is already done in the state manager, why a 2nd time?
- if !miner.ethereum.StateManager().Pow.Verify(miner.block.HashNoNonce(), miner.block.Difficulty, miner.block.Nonce) {
- log.Printf("Second stage verification error: Block's nonce is invalid (= %v)\n", ethutil.Hex(miner.block.Nonce))
- }
- */
miner.ethereum.Broadcast(ethwire.MsgBlockTy, []interface{}{miner.block.Value().Val})
log.Printf("[MINER] 🔨 Mined block %x\n", miner.block.Hash())