From 1ccae1302b5b8ed44d3702fcca6bb833ea960aec Mon Sep 17 00:00:00 2001 From: Paladz Date: Mon, 13 Nov 2017 17:04:37 +0800 Subject: [PATCH] Bvm (#100) * chain.state using block.height instead of height * define the template structure for coinbase transaction * fix for code review, golint and elegant * fix a acp key error * fix for hsm_test bug * fix bug for list account * fix for code review * add log info to mining --- blockchain/reactor.go | 2 ++ mining/cpuminer/cpuminer.go | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/blockchain/reactor.go b/blockchain/reactor.go index 3878dbe2..5acf68da 100644 --- a/blockchain/reactor.go +++ b/blockchain/reactor.go @@ -240,6 +240,7 @@ func NewBlockchainReactor(chain *protocol.Chain, txPool *protocol.TxPool, accoun func (bcR *BlockchainReactor) OnStart() error { bcR.BaseReactor.OnStart() bcR.BuildHander() + bcR.mining.Start() go bcR.syncRoutine() return nil @@ -248,6 +249,7 @@ func (bcR *BlockchainReactor) OnStart() error { // OnStop implements BaseService func (bcR *BlockchainReactor) OnStop() { bcR.BaseReactor.OnStop() + bcR.mining.Stop() } // GetChannels implements Reactor diff --git a/mining/cpuminer/cpuminer.go b/mining/cpuminer/cpuminer.go index dbd660c6..4ead54ae 100644 --- a/mining/cpuminer/cpuminer.go +++ b/mining/cpuminer/cpuminer.go @@ -189,10 +189,11 @@ func (m *CPUMiner) Start() { m.quit = make(chan struct{}) m.speedMonitorQuit = make(chan struct{}) - m.wg.Add(2) + m.wg.Add(1) go m.miningWorkerController() m.started = true + log.Infof("CPU miner started") } // Stop gracefully stops the mining process by signalling all workers, and the @@ -213,6 +214,7 @@ func (m *CPUMiner) Stop() { close(m.quit) m.wg.Wait() m.started = false + log.Info("CPU miner stopped") } // IsMining returns whether or not the CPU miner has been started and is -- 2.11.0