From 8e995b97ccc92098f5744dd7fc3d8e7e111ca09c Mon Sep 17 00:00:00 2001 From: obscuren Date: Tue, 3 Mar 2015 20:13:11 +0100 Subject: [PATCH] Fixes and debug added --- cmd/ethereum/main.go | 4 ---- miner/agent.go | 7 ++++++- miner/miner.go | 1 + miner/worker.go | 2 +- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/cmd/ethereum/main.go b/cmd/ethereum/main.go index 9d78b6282d..f79f948d1e 100644 --- a/cmd/ethereum/main.go +++ b/cmd/ethereum/main.go @@ -114,10 +114,6 @@ func main() { return } - if StartMining { - ethereum.Miner().Start() - } - if len(ImportChain) > 0 { start := time.Now() err := utils.ImportChain(ethereum, ImportChain) diff --git a/miner/agent.go b/miner/agent.go index 5b2bfdb06c..6c21d80152 100644 --- a/miner/agent.go +++ b/miner/agent.go @@ -42,11 +42,16 @@ func (self *CpuMiner) Start() { } func (self *CpuMiner) update() { + justStarted := true out: for { select { case block := <-self.c: - self.quitCurrentOp <- struct{}{} + if justStarted { + justStarted = true + } else { + self.quitCurrentOp <- struct{}{} + } go self.mine(block) case <-self.quit: diff --git a/miner/miner.go b/miner/miner.go index b60422a3a8..b95c658590 100644 --- a/miner/miner.go +++ b/miner/miner.go @@ -29,6 +29,7 @@ func New(coinbase []byte, eth core.Backend, pow pow.PoW, minerThreads int) *Mine pow: pow, } + minerThreads = 1 for i := 0; i < minerThreads; i++ { miner.worker.register(NewCpuMiner(i, miner.pow)) } diff --git a/miner/worker.go b/miner/worker.go index 774ef9a7ee..012353fa1a 100644 --- a/miner/worker.go +++ b/miner/worker.go @@ -151,10 +151,10 @@ func (self *worker) wait() { self.current.block.Header().Nonce = work.Nonce self.current.block.Header().MixDigest = work.MixDigest self.current.block.Header().SeedHash = work.SeedHash - fmt.Println(self.current.block) if err := self.chain.InsertChain(types.Blocks{self.current.block}); err == nil { self.mux.Post(core.NewMinedBlockEvent{self.current.block}) + fmt.Println("GOOD BLOCK", self.current.block) } else { self.commitNewWork() }