aboutsummaryrefslogtreecommitdiffstats
path: root/miner
diff options
context:
space:
mode:
authorJeffrey Wilcke <jeffrey@ethereum.org>2015-05-21 19:11:36 +0800
committerJeffrey Wilcke <jeffrey@ethereum.org>2015-05-21 19:11:36 +0800
commitbf7dcfce368692e1dc605c691504646eef14a645 (patch)
tree0a33c44b7bd589c278f9eda3dabd3e719ad43be2 /miner
parent9bde7fd72e738865e6ed3208495f966f4f21daac (diff)
parent907848997bbf79382a98b0c82e4aa61ca2eecd16 (diff)
downloaddexon-bf7dcfce368692e1dc605c691504646eef14a645.tar
dexon-bf7dcfce368692e1dc605c691504646eef14a645.tar.gz
dexon-bf7dcfce368692e1dc605c691504646eef14a645.tar.bz2
dexon-bf7dcfce368692e1dc605c691504646eef14a645.tar.lz
dexon-bf7dcfce368692e1dc605c691504646eef14a645.tar.xz
dexon-bf7dcfce368692e1dc605c691504646eef14a645.tar.zst
dexon-bf7dcfce368692e1dc605c691504646eef14a645.zip
Merge pull request #1059 from obscuren/cleanup
Cleanup
Diffstat (limited to 'miner')
-rw-r--r--miner/miner.go6
1 files changed, 6 insertions, 0 deletions
diff --git a/miner/miner.go b/miner/miner.go
index 3f87e8151..c9427f302 100644
--- a/miner/miner.go
+++ b/miner/miner.go
@@ -39,6 +39,10 @@ func New(eth core.Backend, mux *event.TypeMux, pow pow.PoW) *Miner {
return miner
}
+// update keeps track of the downloader events. Please be aware that this is a one shot type of update loop.
+// It's entered once and as soon as `Done` or `Failed` has been broadcasted the events are unregistered and
+// the loop is exited. This to prevent a major security vuln where external parties can DOS you with blocks
+// and halt your mining operation for as long as the DOS continues.
func (self *Miner) update() {
events := self.mux.Subscribe(downloader.StartEvent{}, downloader.DoneEvent{}, downloader.FailedEvent{})
for ev := range events.Chan() {
@@ -59,6 +63,8 @@ func (self *Miner) update() {
self.Start(self.coinbase, self.threads)
}
}
+ // unsubscribe. we're only interested in this event once
+ events.Unsubscribe()
}
}