@@ -21,14 +21,11 @@ import (
21
21
"errors"
22
22
"fmt"
23
23
"math/big"
24
- "os"
25
- "path/filepath"
26
24
"regexp"
27
25
"strings"
28
26
"sync"
29
27
"time"
30
28
31
- "github.com/ethereum/ethash"
32
29
"github.com/ethereum/go-ethereum/accounts"
33
30
"github.com/ethereum/go-ethereum/common"
34
31
"github.com/ethereum/go-ethereum/core"
@@ -78,7 +75,6 @@ type Config struct {
78
75
DatabaseHandles int
79
76
80
77
DocRoot string
81
- AutoDAG bool
82
78
PowFake bool
83
79
PowTest bool
84
80
PowShared bool
@@ -88,6 +84,7 @@ type Config struct {
88
84
EthashCachesInMem int
89
85
EthashCachesOnDisk int
90
86
EthashDatasetDir string
87
+ EthashDatasetsInMem int
91
88
EthashDatasetsOnDisk int
92
89
93
90
Etherbase common.Address
@@ -138,8 +135,6 @@ type Ethereum struct {
138
135
miner * miner.Miner
139
136
Mining bool
140
137
MinerThreads int
141
- AutoDAG bool
142
- autodagquit chan bool
143
138
etherbase common.Address
144
139
solcPath string
145
140
@@ -173,7 +168,6 @@ func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) {
173
168
netVersionId : config .NetworkId ,
174
169
etherbase : config .Etherbase ,
175
170
MinerThreads : config .MinerThreads ,
176
- AutoDAG : config .AutoDAG ,
177
171
solcPath : config .SolcPath ,
178
172
}
179
173
@@ -298,7 +292,7 @@ func CreatePoW(ctx *node.ServiceContext, config *Config) pow.PoW {
298
292
return pow .NewSharedEthash ()
299
293
default :
300
294
return pow .NewFullEthash (ctx .ResolvePath (config .EthashCacheDir ), config .EthashCachesInMem , config .EthashCachesOnDisk ,
301
- config .EthashDatasetDir , config .EthashDatasetsOnDisk )
295
+ config .EthashDatasetDir , config .EthashDatasetsInMem , config . EthashDatasetsOnDisk )
302
296
}
303
297
}
304
298
@@ -414,9 +408,7 @@ func (s *Ethereum) Protocols() []p2p.Protocol {
414
408
// Ethereum protocol implementation.
415
409
func (s * Ethereum ) Start (srvr * p2p.Server ) error {
416
410
s .netRPCService = ethapi .NewPublicNetAPI (srvr , s .NetVersion ())
417
- if s .AutoDAG {
418
- s .StartAutoDAG ()
419
- }
411
+
420
412
s .protocolManager .Start ()
421
413
if s .lesServer != nil {
422
414
s .lesServer .Start (srvr )
@@ -439,8 +431,6 @@ func (s *Ethereum) Stop() error {
439
431
s .miner .Stop ()
440
432
s .eventMux .Stop ()
441
433
442
- s .StopAutoDAG ()
443
-
444
434
s .chainDb .Close ()
445
435
close (s .shutdownChan )
446
436
@@ -451,74 +441,3 @@ func (s *Ethereum) Stop() error {
451
441
func (s * Ethereum ) WaitForShutdown () {
452
442
<- s .shutdownChan
453
443
}
454
-
455
- // StartAutoDAG() spawns a go routine that checks the DAG every autoDAGcheckInterval
456
- // by default that is 10 times per epoch
457
- // in epoch n, if we past autoDAGepochHeight within-epoch blocks,
458
- // it calls ethash.MakeDAG to pregenerate the DAG for the next epoch n+1
459
- // if it does not exist yet as well as remove the DAG for epoch n-1
460
- // the loop quits if autodagquit channel is closed, it can safely restart and
461
- // stop any number of times.
462
- // For any more sophisticated pattern of DAG generation, use CLI subcommand
463
- // makedag
464
- func (self * Ethereum ) StartAutoDAG () {
465
- if self .autodagquit != nil {
466
- return // already started
467
- }
468
- go func () {
469
- log .Info ("Pre-generation of ethash DAG on" , "dir" , ethash .DefaultDir )
470
- var nextEpoch uint64
471
- timer := time .After (0 )
472
- self .autodagquit = make (chan bool )
473
- for {
474
- select {
475
- case <- timer :
476
- log .Info ("Checking DAG availability" , "dir" , ethash .DefaultDir )
477
- currentBlock := self .BlockChain ().CurrentBlock ().NumberU64 ()
478
- thisEpoch := currentBlock / epochLength
479
- if nextEpoch <= thisEpoch {
480
- if currentBlock % epochLength > autoDAGepochHeight {
481
- if thisEpoch > 0 {
482
- previousDag , previousDagFull := dagFiles (thisEpoch - 1 )
483
- os .Remove (filepath .Join (ethash .DefaultDir , previousDag ))
484
- os .Remove (filepath .Join (ethash .DefaultDir , previousDagFull ))
485
- log .Info ("Removed previous DAG" , "epoch" , thisEpoch - 1 , "dag" , previousDag )
486
- }
487
- nextEpoch = thisEpoch + 1
488
- dag , _ := dagFiles (nextEpoch )
489
- if _ , err := os .Stat (dag ); os .IsNotExist (err ) {
490
- log .Info ("Pre-generating next DAG" , "epoch" , nextEpoch , "dag" , dag )
491
- err := ethash .MakeDAG (nextEpoch * epochLength , "" ) // "" -> ethash.DefaultDir
492
- if err != nil {
493
- log .Error ("Error generating DAG" , "epoch" , nextEpoch , "dag" , dag , "err" , err )
494
- return
495
- }
496
- } else {
497
- log .Warn ("DAG already exists" , "epoch" , nextEpoch , "dag" , dag )
498
- }
499
- }
500
- }
501
- timer = time .After (autoDAGcheckInterval )
502
- case <- self .autodagquit :
503
- return
504
- }
505
- }
506
- }()
507
- }
508
-
509
- // stopAutoDAG stops automatic DAG pregeneration by quitting the loop
510
- func (self * Ethereum ) StopAutoDAG () {
511
- if self .autodagquit != nil {
512
- close (self .autodagquit )
513
- self .autodagquit = nil
514
- }
515
- log .Info ("Pre-generation of ethash DAG off" , "dir" , ethash .DefaultDir )
516
- }
517
-
518
- // dagFiles(epoch) returns the two alternative DAG filenames (not a path)
519
- // 1) <revision>-<hex(seedhash[8])> 2) full-R<revision>-<hex(seedhash[8])>
520
- func dagFiles (epoch uint64 ) (string , string ) {
521
- seedHash , _ := ethash .GetSeedHash (epoch * epochLength )
522
- dag := fmt .Sprintf ("full-R%d-%x" , ethashRevision , seedHash [:8 ])
523
- return dag , "full-R" + dag
524
- }
0 commit comments