good morning!!!!
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
bor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
open
bor
Commits
badbaf66
Commit
badbaf66
authored
Apr 8, 2017
by
Péter Szilágyi
Committed by
GitHub
Apr 8, 2017
Browse files
Options
Downloads
Plain Diff
Merge pull request #13880 from karalabe/remote-miner-fix
consensus/ethash, eth: don't mine if 0 threads are set
parents
cc13d576
b801be99
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
consensus/ethash/ethash.go
+8
-1
8 additions, 1 deletion
consensus/ethash/ethash.go
consensus/ethash/sealer.go
+3
-0
3 additions, 0 deletions
consensus/ethash/sealer.go
eth/api.go
+17
-10
17 additions, 10 deletions
eth/api.go
eth/backend.go
+3
-1
3 additions, 1 deletion
eth/backend.go
with
31 additions
and
12 deletions
consensus/ethash/ethash.go
+
8
−
1
View file @
badbaf66
...
@@ -555,11 +555,18 @@ func (ethash *Ethash) Threads() int {
...
@@ -555,11 +555,18 @@ func (ethash *Ethash) Threads() int {
// SetThreads updates the number of mining threads currently enabled. Calling
// SetThreads updates the number of mining threads currently enabled. Calling
// this method does not start mining, only sets the thread count. If zero is
// this method does not start mining, only sets the thread count. If zero is
// specified, the miner will use all cores of the machine.
// specified, the miner will use all cores of the machine. Setting a thread
// count below zero is allowed and will cause the miner to idle, without any
// work being done.
func
(
ethash
*
Ethash
)
SetThreads
(
threads
int
)
{
func
(
ethash
*
Ethash
)
SetThreads
(
threads
int
)
{
ethash
.
lock
.
Lock
()
ethash
.
lock
.
Lock
()
defer
ethash
.
lock
.
Unlock
()
defer
ethash
.
lock
.
Unlock
()
// If we're running a shared PoW, set the thread count on that instead
if
ethash
.
shared
!=
nil
{
ethash
.
shared
.
SetThreads
(
threads
)
return
}
// Update the threads and ping any running seal to pull in any changes
// Update the threads and ping any running seal to pull in any changes
ethash
.
threads
=
threads
ethash
.
threads
=
threads
select
{
select
{
...
...
This diff is collapsed.
Click to expand it.
consensus/ethash/sealer.go
+
3
−
0
View file @
badbaf66
...
@@ -61,6 +61,9 @@ func (ethash *Ethash) Seal(chain consensus.ChainReader, block *types.Block, stop
...
@@ -61,6 +61,9 @@ func (ethash *Ethash) Seal(chain consensus.ChainReader, block *types.Block, stop
if
threads
==
0
{
if
threads
==
0
{
threads
=
runtime
.
NumCPU
()
threads
=
runtime
.
NumCPU
()
}
}
if
threads
<
0
{
threads
=
0
// Allows disabling local mining without extra logic around local/remote
}
var
pend
sync
.
WaitGroup
var
pend
sync
.
WaitGroup
for
i
:=
0
;
i
<
threads
;
i
++
{
for
i
:=
0
;
i
<
threads
;
i
++
{
pend
.
Add
(
1
)
pend
.
Add
(
1
)
...
...
This diff is collapsed.
Click to expand it.
eth/api.go
+
17
−
10
View file @
badbaf66
...
@@ -139,16 +139,17 @@ func NewPrivateMinerAPI(e *Ethereum) *PrivateMinerAPI {
...
@@ -139,16 +139,17 @@ func NewPrivateMinerAPI(e *Ethereum) *PrivateMinerAPI {
// threads allowed to use.
// threads allowed to use.
func
(
api
*
PrivateMinerAPI
)
Start
(
threads
*
int
)
error
{
func
(
api
*
PrivateMinerAPI
)
Start
(
threads
*
int
)
error
{
// Set the number of threads if the seal engine supports it
// Set the number of threads if the seal engine supports it
if
threads
!=
nil
{
if
threads
==
nil
{
threads
=
new
(
int
)
}
else
if
*
threads
==
0
{
*
threads
=
-
1
// Disable the miner from within
}
type
threaded
interface
{
type
threaded
interface
{
SetThreads
(
threads
int
)
SetThreads
(
threads
int
)
}
}
if
th
,
ok
:=
api
.
e
.
engine
.
(
threaded
);
ok
{
if
th
,
ok
:=
api
.
e
.
engine
.
(
threaded
);
ok
{
log
.
Info
(
"Updated mining threads"
,
"threads"
,
*
threads
)
log
.
Info
(
"Updated mining threads"
,
"threads"
,
*
threads
)
th
.
SetThreads
(
*
threads
)
th
.
SetThreads
(
*
threads
)
}
else
{
log
.
Warn
(
"Current seal engine isn't threaded"
)
}
}
}
// Start the miner and return
// Start the miner and return
if
!
api
.
e
.
IsMining
()
{
if
!
api
.
e
.
IsMining
()
{
...
@@ -159,6 +160,12 @@ func (api *PrivateMinerAPI) Start(threads *int) error {
...
@@ -159,6 +160,12 @@ func (api *PrivateMinerAPI) Start(threads *int) error {
// Stop the miner
// Stop the miner
func
(
api
*
PrivateMinerAPI
)
Stop
()
bool
{
func
(
api
*
PrivateMinerAPI
)
Stop
()
bool
{
type
threaded
interface
{
SetThreads
(
threads
int
)
}
if
th
,
ok
:=
api
.
e
.
engine
.
(
threaded
);
ok
{
th
.
SetThreads
(
-
1
)
}
api
.
e
.
StopMining
()
api
.
e
.
StopMining
()
return
true
return
true
}
}
...
...
This diff is collapsed.
Click to expand it.
eth/backend.go
+
3
−
1
View file @
badbaf66
...
@@ -240,8 +240,10 @@ func CreateConsensusEngine(ctx *node.ServiceContext, config *Config, chainConfig
...
@@ -240,8 +240,10 @@ func CreateConsensusEngine(ctx *node.ServiceContext, config *Config, chainConfig
log
.
Warn
(
"Ethash used in shared mode"
)
log
.
Warn
(
"Ethash used in shared mode"
)
return
ethash
.
NewShared
()
return
ethash
.
NewShared
()
default
:
default
:
return
ethash
.
New
(
ctx
.
ResolvePath
(
config
.
EthashCacheDir
),
config
.
EthashCachesInMem
,
config
.
EthashCachesOnDisk
,
engine
:=
ethash
.
New
(
ctx
.
ResolvePath
(
config
.
EthashCacheDir
),
config
.
EthashCachesInMem
,
config
.
EthashCachesOnDisk
,
config
.
EthashDatasetDir
,
config
.
EthashDatasetsInMem
,
config
.
EthashDatasetsOnDisk
)
config
.
EthashDatasetDir
,
config
.
EthashDatasetsInMem
,
config
.
EthashDatasetsOnDisk
)
engine
.
SetThreads
(
-
1
)
// Disable CPU mining
return
engine
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment