aboutsummaryrefslogtreecommitdiffstats
path: root/miner/agent.go
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2015-05-11 21:43:14 +0800
committerobscuren <geffobscura@gmail.com>2015-05-11 23:21:22 +0800
commit21e52efdfed19c4376b830f8ad0e52a9e599f633 (patch)
treea3d6f2be23c64881461892572adc9d1b55cd4b39 /miner/agent.go
parent064cf1609987bb0f6c59c1e790b7811d9a783fef (diff)
downloadgo-tangerine-21e52efdfed19c4376b830f8ad0e52a9e599f633.tar.gz
go-tangerine-21e52efdfed19c4376b830f8ad0e52a9e599f633.tar.zst
go-tangerine-21e52efdfed19c4376b830f8ad0e52a9e599f633.zip
cmd/geth, miner, backend, xeth: Fixed miner threads to be settable
Miner threads are now settable through the admin interface (closes #897) and specify 0 CPU worker threads when eth_getWork is called (closes #916)
Diffstat (limited to 'miner/agent.go')
-rw-r--r--miner/agent.go22
1 files changed, 11 insertions, 11 deletions
diff --git a/miner/agent.go b/miner/agent.go
index b2f89aaab..939f63fef 100644
--- a/miner/agent.go
+++ b/miner/agent.go
@@ -10,7 +10,7 @@ import (
"github.com/ethereum/go-ethereum/pow"
)
-type CpuMiner struct {
+type CpuAgent struct {
chMu sync.Mutex
c chan *types.Block
quit chan struct{}
@@ -21,8 +21,8 @@ type CpuMiner struct {
pow pow.PoW
}
-func NewCpuMiner(index int, pow pow.PoW) *CpuMiner {
- miner := &CpuMiner{
+func NewCpuAgent(index int, pow pow.PoW) *CpuAgent {
+ miner := &CpuAgent{
pow: pow,
index: index,
}
@@ -30,16 +30,16 @@ func NewCpuMiner(index int, pow pow.PoW) *CpuMiner {
return miner
}
-func (self *CpuMiner) Work() chan<- *types.Block { return self.c }
-func (self *CpuMiner) Pow() pow.PoW { return self.pow }
-func (self *CpuMiner) SetReturnCh(ch chan<- *types.Block) { self.returnCh = ch }
+func (self *CpuAgent) Work() chan<- *types.Block { return self.c }
+func (self *CpuAgent) Pow() pow.PoW { return self.pow }
+func (self *CpuAgent) SetReturnCh(ch chan<- *types.Block) { self.returnCh = ch }
-func (self *CpuMiner) Stop() {
+func (self *CpuAgent) Stop() {
close(self.quit)
close(self.quitCurrentOp)
}
-func (self *CpuMiner) Start() {
+func (self *CpuAgent) Start() {
self.quit = make(chan struct{})
self.quitCurrentOp = make(chan struct{}, 1)
self.c = make(chan *types.Block, 1)
@@ -47,7 +47,7 @@ func (self *CpuMiner) Start() {
go self.update()
}
-func (self *CpuMiner) update() {
+func (self *CpuAgent) update() {
out:
for {
select {
@@ -76,7 +76,7 @@ done:
}
}
-func (self *CpuMiner) mine(block *types.Block) {
+func (self *CpuAgent) mine(block *types.Block) {
glog.V(logger.Debug).Infof("(re)started agent[%d]. mining...\n", self.index)
// Reset the channel
@@ -95,6 +95,6 @@ func (self *CpuMiner) mine(block *types.Block) {
}
}
-func (self *CpuMiner) GetHashRate() int64 {
+func (self *CpuAgent) GetHashRate() int64 {
return self.pow.GetHashrate()
}