5050 two256 = new (big.Int ).Exp (big .NewInt (2 ), big .NewInt (256 ), big .NewInt (0 ))
5151
5252 // sharedEthash is a full instance that can be shared between multiple users.
53- sharedEthash = New (Config {"" , 3 , 0 , "" , 1 , 0 , ModeNormal }, nil )
53+ sharedEthash = New (Config {"" , 3 , 0 , "" , 1 , 0 , ModeNormal }, nil , false )
5454
5555 // algorithmRevision is the data structure version used for file naming.
5656 algorithmRevision = 23
@@ -405,6 +405,12 @@ type Config struct {
405405 PowMode Mode
406406}
407407
408+ // sealTask wraps a seal block with relative result channel for remote sealer thread.
409+ type sealTask struct {
410+ block * types.Block
411+ results chan <- * types.Block
412+ }
413+
408414// mineResult wraps the pow solution parameters for the specified block.
409415type mineResult struct {
410416 nonce types.BlockNonce
@@ -444,12 +450,11 @@ type Ethash struct {
444450 hashrate metrics.Meter // Meter tracking the average hashrate
445451
446452 // Remote sealer related fields
447- workCh chan * types.Block // Notification channel to push new work to remote sealer
448- resultCh chan * types.Block // Channel used by mining threads to return result
449- fetchWorkCh chan * sealWork // Channel used for remote sealer to fetch mining work
450- submitWorkCh chan * mineResult // Channel used for remote sealer to submit their mining result
451- fetchRateCh chan chan uint64 // Channel used to gather submitted hash rate for local or remote sealer.
452- submitRateCh chan * hashrate // Channel used for remote sealer to submit their mining hashrate
453+ workCh chan * sealTask // Notification channel to push new work and relative result channel to remote sealer
454+ fetchWorkCh chan * sealWork // Channel used for remote sealer to fetch mining work
455+ submitWorkCh chan * mineResult // Channel used for remote sealer to submit their mining result
456+ fetchRateCh chan chan uint64 // Channel used to gather submitted hash rate for local or remote sealer.
457+ submitRateCh chan * hashrate // Channel used for remote sealer to submit their mining hashrate
453458
454459 // The fields below are hooks for testing
455460 shared * Ethash // Shared PoW verifier to avoid cache regeneration
@@ -464,7 +469,7 @@ type Ethash struct {
464469// New creates a full sized ethash PoW scheme and starts a background thread for
465470// remote mining, also optionally notifying a batch of remote services of new work
466471// packages.
467- func New (config Config , notify []string ) * Ethash {
472+ func New (config Config , notify []string , noverify bool ) * Ethash {
468473 if config .CachesInMem <= 0 {
469474 log .Warn ("One ethash cache must always be in memory" , "requested" , config .CachesInMem )
470475 config .CachesInMem = 1
@@ -481,36 +486,34 @@ func New(config Config, notify []string) *Ethash {
481486 datasets : newlru ("dataset" , config .DatasetsInMem , newDataset ),
482487 update : make (chan struct {}),
483488 hashrate : metrics .NewMeter (),
484- workCh : make (chan * types.Block ),
485- resultCh : make (chan * types.Block ),
489+ workCh : make (chan * sealTask ),
486490 fetchWorkCh : make (chan * sealWork ),
487491 submitWorkCh : make (chan * mineResult ),
488492 fetchRateCh : make (chan chan uint64 ),
489493 submitRateCh : make (chan * hashrate ),
490494 exitCh : make (chan chan error ),
491495 }
492- go ethash .remote (notify )
496+ go ethash .remote (notify , noverify )
493497 return ethash
494498}
495499
496500// NewTester creates a small sized ethash PoW scheme useful only for testing
497501// purposes.
498- func NewTester (notify []string ) * Ethash {
502+ func NewTester (notify []string , noverify bool ) * Ethash {
499503 ethash := & Ethash {
500504 config : Config {PowMode : ModeTest },
501505 caches : newlru ("cache" , 1 , newCache ),
502506 datasets : newlru ("dataset" , 1 , newDataset ),
503507 update : make (chan struct {}),
504508 hashrate : metrics .NewMeter (),
505- workCh : make (chan * types.Block ),
506- resultCh : make (chan * types.Block ),
509+ workCh : make (chan * sealTask ),
507510 fetchWorkCh : make (chan * sealWork ),
508511 submitWorkCh : make (chan * mineResult ),
509512 fetchRateCh : make (chan chan uint64 ),
510513 submitRateCh : make (chan * hashrate ),
511514 exitCh : make (chan chan error ),
512515 }
513- go ethash .remote (notify )
516+ go ethash .remote (notify , noverify )
514517 return ethash
515518}
516519
0 commit comments