aboutsummaryrefslogtreecommitdiffstats
path: root/consensus/ethash/ethash.go
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2018-08-08 17:15:08 +0800
committerPéter Szilágyi <peterke@gmail.com>2018-08-10 14:06:59 +0800
commitf0998415ba9a73f0add32f9b5aed2aec98b9a7f3 (patch)
treef85ad72f6213fc953b3174378d7c7443cc1d1dd5 /consensus/ethash/ethash.go
parent00e6da9704b2cd7ddcc1cd31ed3f6bbaa8e1e284 (diff)
downloaddexon-f0998415ba9a73f0add32f9b5aed2aec98b9a7f3.tar
dexon-f0998415ba9a73f0add32f9b5aed2aec98b9a7f3.tar.gz
dexon-f0998415ba9a73f0add32f9b5aed2aec98b9a7f3.tar.bz2
dexon-f0998415ba9a73f0add32f9b5aed2aec98b9a7f3.tar.lz
dexon-f0998415ba9a73f0add32f9b5aed2aec98b9a7f3.tar.xz
dexon-f0998415ba9a73f0add32f9b5aed2aec98b9a7f3.tar.zst
dexon-f0998415ba9a73f0add32f9b5aed2aec98b9a7f3.zip
cmd, consensus/ethash, eth: miner push notifications
Diffstat (limited to 'consensus/ethash/ethash.go')
-rw-r--r--consensus/ethash/ethash.go18
1 files changed, 10 insertions, 8 deletions
diff --git a/consensus/ethash/ethash.go b/consensus/ethash/ethash.go
index 0cb3059b9..19c94deb6 100644
--- a/consensus/ethash/ethash.go
+++ b/consensus/ethash/ethash.go
@@ -45,11 +45,11 @@ import (
var ErrInvalidDumpMagic = errors.New("invalid dump magic")
var (
- // maxUint256 is a big integer representing 2^256-1
- maxUint256 = new(big.Int).Exp(big.NewInt(2), big.NewInt(256), big.NewInt(0))
+ // two256 is a big integer representing 2^256
+ two256 = new(big.Int).Exp(big.NewInt(2), big.NewInt(256), big.NewInt(0))
// sharedEthash is a full instance that can be shared between multiple users.
- sharedEthash = New(Config{"", 3, 0, "", 1, 0, ModeNormal})
+ sharedEthash = New(Config{"", 3, 0, "", 1, 0, ModeNormal}, nil)
// algorithmRevision is the data structure version used for file naming.
algorithmRevision = 23
@@ -447,8 +447,10 @@ type Ethash struct {
exitCh chan chan error // Notification channel to exiting backend threads
}
-// New creates a full sized ethash PoW scheme and starts a background thread for remote mining.
-func New(config Config) *Ethash {
+// New creates a full sized ethash PoW scheme and starts a background thread for
+// remote mining, also optionally notifying a batch of remote services of new work
+// packages.
+func New(config Config, notify []string) *Ethash {
if config.CachesInMem <= 0 {
log.Warn("One ethash cache must always be in memory", "requested", config.CachesInMem)
config.CachesInMem = 1
@@ -473,13 +475,13 @@ func New(config Config) *Ethash {
submitRateCh: make(chan *hashrate),
exitCh: make(chan chan error),
}
- go ethash.remote()
+ go ethash.remote(notify)
return ethash
}
// NewTester creates a small sized ethash PoW scheme useful only for testing
// purposes.
-func NewTester() *Ethash {
+func NewTester(notify []string) *Ethash {
ethash := &Ethash{
config: Config{PowMode: ModeTest},
caches: newlru("cache", 1, newCache),
@@ -494,7 +496,7 @@ func NewTester() *Ethash {
submitRateCh: make(chan *hashrate),
exitCh: make(chan chan error),
}
- go ethash.remote()
+ go ethash.remote(notify)
return ethash
}