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
01b83314
Commit
01b83314
authored
May 21, 2014
by
Jeffrey Wilcke
Browse files
Options
Downloads
Patches
Plain Diff
Added mining stop and start
parent
b902de20
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
ethereum/javascript_runtime.go
+14
-1
14 additions, 1 deletion
ethereum/javascript_runtime.go
utils/cmd.go
+30
-8
30 additions, 8 deletions
utils/cmd.go
with
44 additions
and
9 deletions
ethereum/javascript_runtime.go
+
14
−
1
View file @
01b83314
...
@@ -6,6 +6,7 @@ import (
...
@@ -6,6 +6,7 @@ import (
"github.com/ethereum/eth-go/ethchain"
"github.com/ethereum/eth-go/ethchain"
"github.com/ethereum/eth-go/ethpub"
"github.com/ethereum/eth-go/ethpub"
"github.com/ethereum/eth-go/ethutil"
"github.com/ethereum/eth-go/ethutil"
"github.com/ethereum/go-ethereum/utils"
"github.com/obscuren/otto"
"github.com/obscuren/otto"
"io/ioutil"
"io/ioutil"
"os"
"os"
...
@@ -116,14 +117,26 @@ func (self *JSRE) initStdFuncs() {
...
@@ -116,14 +117,26 @@ func (self *JSRE) initStdFuncs() {
eth
.
Set
(
"watch"
,
self
.
watch
)
eth
.
Set
(
"watch"
,
self
.
watch
)
eth
.
Set
(
"addPeer"
,
self
.
addPeer
)
eth
.
Set
(
"addPeer"
,
self
.
addPeer
)
eth
.
Set
(
"require"
,
self
.
require
)
eth
.
Set
(
"require"
,
self
.
require
)
eth
.
Set
(
"stopMining"
,
self
.
stopMining
)
eth
.
Set
(
"startMining"
,
self
.
startMining
)
}
}
/*
/*
* The following methods are natively implemented javascript functions
* The following methods are natively implemented javascript functions
*/
*/
func
(
self
*
JSRE
)
stopMining
(
call
otto
.
FunctionCall
)
otto
.
Value
{
v
,
_
:=
self
.
vm
.
ToValue
(
utils
.
StopMining
(
self
.
ethereum
))
return
v
}
func
(
self
*
JSRE
)
startMining
(
call
otto
.
FunctionCall
)
otto
.
Value
{
v
,
_
:=
self
.
vm
.
ToValue
(
utils
.
StartMining
(
self
.
ethereum
))
return
v
}
// eth.watch
// eth.watch
func
(
self
JSRE
)
watch
(
call
otto
.
FunctionCall
)
otto
.
Value
{
func
(
self
*
JSRE
)
watch
(
call
otto
.
FunctionCall
)
otto
.
Value
{
addr
,
_
:=
call
.
Argument
(
0
)
.
ToString
()
addr
,
_
:=
call
.
Argument
(
0
)
.
ToString
()
var
storageAddr
string
var
storageAddr
string
var
cb
otto
.
Value
var
cb
otto
.
Value
...
...
This diff is collapsed.
Click to expand it.
utils/cmd.go
+
30
−
8
View file @
01b83314
...
@@ -19,6 +19,8 @@ func DoRpc(ethereum *eth.Ethereum, RpcPort int) {
...
@@ -19,6 +19,8 @@ func DoRpc(ethereum *eth.Ethereum, RpcPort int) {
}
}
}
}
var
miner
ethminer
.
Miner
func
DoMining
(
ethereum
*
eth
.
Ethereum
)
{
func
DoMining
(
ethereum
*
eth
.
Ethereum
)
{
// Set Mining status
// Set Mining status
ethereum
.
Mining
=
true
ethereum
.
Mining
=
true
...
@@ -31,17 +33,37 @@ func DoMining(ethereum *eth.Ethereum) {
...
@@ -31,17 +33,37 @@ func DoMining(ethereum *eth.Ethereum) {
addr
:=
keyPair
.
Address
()
addr
:=
keyPair
.
Address
()
go
func
()
{
go
func
()
{
ethutil
.
Config
.
Log
.
Infoln
(
"Miner started"
)
miner
=
ethminer
.
NewDefaultMiner
(
addr
,
ethereum
)
// Give it some time to connect with peers
// Give it some time to connect with peers
time
.
Sleep
(
3
*
time
.
Second
)
time
.
Sleep
(
3
*
time
.
Second
)
/*
for ethereum.IsUpToDate() == false {
time.Sleep(5 * time.Second)
}
*/
ethutil
.
Config
.
Log
.
Infoln
(
"Miner started"
)
miner
:=
ethminer
.
NewDefaultMiner
(
addr
,
ethereum
)
miner
.
Start
()
miner
.
Start
()
}()
}()
}
}
func
StopMining
(
ethereum
*
eth
.
Ethereum
)
bool
{
if
ethereum
.
Mining
{
miner
.
Stop
()
ethutil
.
Config
.
Log
.
Infoln
(
"Miner stopped"
)
ethereum
.
Mining
=
false
return
true
}
return
false
}
func
StartMining
(
ethereum
*
eth
.
Ethereum
)
bool
{
if
!
ethereum
.
Mining
{
DoMining
(
ethereum
)
return
true
}
return
false
}
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