aboutsummaryrefslogtreecommitdiffstats
path: root/miner
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2017-03-06 02:00:01 +0800
committerFelix Lange <fjl@users.noreply.github.com>2017-03-09 22:50:14 +0800
commit567d41d9363706b4b13ce0903804e8acf214af49 (patch)
tree8c091f0385589074573df3f7964c99417c5950ee /miner
parent3b00a77de57ab2737a7887521c192ce004c721e3 (diff)
downloadgo-tangerine-567d41d9363706b4b13ce0903804e8acf214af49.tar
go-tangerine-567d41d9363706b4b13ce0903804e8acf214af49.tar.gz
go-tangerine-567d41d9363706b4b13ce0903804e8acf214af49.tar.bz2
go-tangerine-567d41d9363706b4b13ce0903804e8acf214af49.tar.lz
go-tangerine-567d41d9363706b4b13ce0903804e8acf214af49.tar.xz
go-tangerine-567d41d9363706b4b13ce0903804e8acf214af49.tar.zst
go-tangerine-567d41d9363706b4b13ce0903804e8acf214af49.zip
all: swap out the C++ ethash to the pure Go one (mining todo)
Diffstat (limited to 'miner')
-rw-r--r--miner/agent.go4
-rw-r--r--miner/miner.go2
-rw-r--r--miner/remote_agent.go7
3 files changed, 6 insertions, 7 deletions
diff --git a/miner/agent.go b/miner/agent.go
index 21300b5b9..3c407f20b 100644
--- a/miner/agent.go
+++ b/miner/agent.go
@@ -111,7 +111,7 @@ func (self *CpuAgent) mine(work *Work, stop <-chan struct{}) {
log.Debug(fmt.Sprintf("(re)started agent[%d]. mining...\n", self.index))
// Mine
- nonce, mixDigest := self.pow.Search(work.Block, stop, self.index)
+ nonce, mixDigest := self.pow.Search(work.Block, stop)
if nonce != 0 {
block := work.Block.WithMiningResult(types.EncodeNonce(nonce), common.BytesToHash(mixDigest))
self.returnCh <- &Result{work, block}
@@ -121,5 +121,5 @@ func (self *CpuAgent) mine(work *Work, stop <-chan struct{}) {
}
func (self *CpuAgent) GetHashRate() int64 {
- return self.pow.GetHashrate()
+ return int64(self.pow.Hashrate())
}
diff --git a/miner/miner.go b/miner/miner.go
index 33d77e174..a91e1ef6b 100644
--- a/miner/miner.go
+++ b/miner/miner.go
@@ -159,7 +159,7 @@ func (self *Miner) Mining() bool {
}
func (self *Miner) HashRate() (tot int64) {
- tot += self.pow.GetHashrate()
+ tot += int64(self.pow.Hashrate())
// do we care this might race? is it worth we're rewriting some
// aspects of the worker/locking up agents so we can get an accurate
// hashrate?
diff --git a/miner/remote_agent.go b/miner/remote_agent.go
index ec9d2c199..08c5fc6f0 100644
--- a/miner/remote_agent.go
+++ b/miner/remote_agent.go
@@ -24,7 +24,6 @@ import (
"sync/atomic"
"time"
- "github.com/ethereum/ethash"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/log"
@@ -115,7 +114,7 @@ func (a *RemoteAgent) GetWork() ([3]string, error) {
block := a.currentWork.Block
res[0] = block.HashNoNonce().Hex()
- seedHash, _ := ethash.GetSeedHash(block.NumberU64())
+ seedHash := pow.EthashSeedHash(block.NumberU64())
res[1] = common.BytesToHash(seedHash).Hex()
// Calculate the "target" to be returned to the external miner
n := big.NewInt(1)
@@ -145,8 +144,8 @@ func (a *RemoteAgent) SubmitWork(nonce types.BlockNonce, mixDigest, hash common.
}
// Make sure the PoW solutions is indeed valid
block := work.Block.WithMiningResult(nonce, mixDigest)
- if !a.pow.Verify(block) {
- log.Warn(fmt.Sprintf("Invalid PoW submitted for %x", hash))
+ if err := a.pow.Verify(block); err != nil {
+ log.Warn(fmt.Sprintf("Invalid PoW submitted for %x: %v", hash, err))
return false
}
// Solutions seems to be valid, return to the miner and notify acceptance