Skip to content

Commit

Permalink
Updated blake3pow and progpow to allow setting thread count
Browse files Browse the repository at this point in the history
  • Loading branch information
jdowning100 committed May 17, 2024
1 parent f6f1ee0 commit e287090
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
9 changes: 6 additions & 3 deletions consensus/blake3pow/blake3pow.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ type Config struct {
NotifyFull bool

Log *log.Logger `toml:"-"`
// Number of threads to mine on if mining
NumThreads int
}

// Blake3pow is a proof-of-work consensus engine using the blake3 hash algorithm
Expand Down Expand Up @@ -70,9 +72,10 @@ type Blake3pow struct {
// packages.
func New(config Config, notify []string, noverify bool, logger *log.Logger) *Blake3pow {
blake3pow := &Blake3pow{
config: config,
update: make(chan struct{}),
logger: logger,
config: config,
update: make(chan struct{}),
logger: logger,
threads: config.NumThreads,
}
if config.PowMode == ModeShared {
blake3pow.shared = sharedBlake3pow
Expand Down
2 changes: 2 additions & 0 deletions consensus/consensus.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,8 @@ type Engine interface {
// VerifySeal computes the PowHash and checks if work meets the difficulty
// requirement specified in header
VerifySeal(header *types.WorkObjectHeader) (common.Hash, error)

SetThreads(threads int)
}

func TargetToDifficulty(target *big.Int) *big.Int {
Expand Down
11 changes: 7 additions & 4 deletions consensus/progpow/progpow.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ type Config struct {
NotifyFull bool

Log *log.Logger `toml:"-"`
// Number of threads to mine on if mining
NumThreads int
}

// Progpow is a proof-of-work consensus engine using the blake3 hash algorithm
Expand Down Expand Up @@ -196,10 +198,11 @@ func New(config Config, notify []string, noverify bool, logger *log.Logger) *Pro
}).Info("Disk storage enabled for ethash caches")
}
progpow := &Progpow{
config: config,
caches: newlru("cache", config.CachesInMem, newCache, logger),
update: make(chan struct{}),
logger: logger,
config: config,
caches: newlru("cache", config.CachesInMem, newCache, logger),
update: make(chan struct{}),
logger: logger,
threads: config.NumThreads,
}
if config.PowMode == ModeShared {
progpow.shared = sharedProgpow
Expand Down

0 comments on commit e287090

Please sign in to comment.