good morning!!!!

Skip to content
Snippets Groups Projects
Commit 8e995b97 authored by Jeffrey Wilcke's avatar Jeffrey Wilcke
Browse files

Fixes and debug added

parent 40ff3cac
No related branches found
No related tags found
No related merge requests found
...@@ -114,10 +114,6 @@ func main() { ...@@ -114,10 +114,6 @@ func main() {
return return
} }
if StartMining {
ethereum.Miner().Start()
}
if len(ImportChain) > 0 { if len(ImportChain) > 0 {
start := time.Now() start := time.Now()
err := utils.ImportChain(ethereum, ImportChain) err := utils.ImportChain(ethereum, ImportChain)
......
...@@ -42,11 +42,16 @@ func (self *CpuMiner) Start() { ...@@ -42,11 +42,16 @@ func (self *CpuMiner) Start() {
} }
func (self *CpuMiner) update() { func (self *CpuMiner) update() {
justStarted := true
out: out:
for { for {
select { select {
case block := <-self.c: case block := <-self.c:
if justStarted {
justStarted = true
} else {
self.quitCurrentOp <- struct{}{} self.quitCurrentOp <- struct{}{}
}
go self.mine(block) go self.mine(block)
case <-self.quit: case <-self.quit:
......
...@@ -29,6 +29,7 @@ func New(coinbase []byte, eth core.Backend, pow pow.PoW, minerThreads int) *Mine ...@@ -29,6 +29,7 @@ func New(coinbase []byte, eth core.Backend, pow pow.PoW, minerThreads int) *Mine
pow: pow, pow: pow,
} }
minerThreads = 1
for i := 0; i < minerThreads; i++ { for i := 0; i < minerThreads; i++ {
miner.worker.register(NewCpuMiner(i, miner.pow)) miner.worker.register(NewCpuMiner(i, miner.pow))
} }
......
...@@ -151,10 +151,10 @@ func (self *worker) wait() { ...@@ -151,10 +151,10 @@ func (self *worker) wait() {
self.current.block.Header().Nonce = work.Nonce self.current.block.Header().Nonce = work.Nonce
self.current.block.Header().MixDigest = work.MixDigest self.current.block.Header().MixDigest = work.MixDigest
self.current.block.Header().SeedHash = work.SeedHash self.current.block.Header().SeedHash = work.SeedHash
fmt.Println(self.current.block)
if err := self.chain.InsertChain(types.Blocks{self.current.block}); err == nil { if err := self.chain.InsertChain(types.Blocks{self.current.block}); err == nil {
self.mux.Post(core.NewMinedBlockEvent{self.current.block}) self.mux.Post(core.NewMinedBlockEvent{self.current.block})
fmt.Println("GOOD BLOCK", self.current.block)
} else { } else {
self.commitNewWork() self.commitNewWork()
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment