Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
6af078bd
Commit
6af078bd
authored
Mar 11, 2015
by
Jeffrey Wilcke
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #462 from fjl/miner-coinbase
miner: provide coinbase when starting the miner
parents
5a9f7121
d5aaf413
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
76 additions
and
96 deletions
+76
-96
js.go
cmd/ethereum/js.go
+4
-2
main.go
cmd/ethereum/main.go
+3
-10
miner.qml
cmd/mist/assets/qml/views/miner.qml
+29
-29
network.qml
cmd/mist/assets/qml/views/network.qml
+0
-1
ui_lib.go
cmd/mist/ui_lib.go
+4
-14
backend.go
eth/backend.go
+15
-8
miner.go
miner/miner.go
+10
-20
xeth.go
xeth/xeth.go
+11
-12
No files found.
cmd/ethereum/js.go
View file @
6af078bd
...
...
@@ -249,12 +249,14 @@ func (self *jsre) dump(call otto.FunctionCall) otto.Value {
}
func
(
self
*
jsre
)
stopMining
(
call
otto
.
FunctionCall
)
otto
.
Value
{
self
.
xeth
.
Miner
()
.
Stop
()
self
.
ethereum
.
StopMining
()
return
otto
.
TrueValue
()
}
func
(
self
*
jsre
)
startMining
(
call
otto
.
FunctionCall
)
otto
.
Value
{
self
.
xeth
.
Miner
()
.
Start
()
if
err
:=
self
.
ethereum
.
StartMining
();
err
!=
nil
{
return
otto
.
FalseValue
()
}
return
otto
.
TrueValue
()
}
...
...
cmd/ethereum/main.go
View file @
6af078bd
...
...
@@ -30,7 +30,6 @@ import (
"time"
"github.com/codegangsta/cli"
"github.com/ethereum/go-ethereum/accounts"
"github.com/ethereum/go-ethereum/cmd/utils"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/eth"
...
...
@@ -158,10 +157,7 @@ func run(ctx *cli.Context) {
fmt
.
Printf
(
"Welcome to the FRONTIER
\n
"
)
utils
.
HandleInterrupt
()
eth
,
err
:=
utils
.
GetEthereum
(
ClientIdentifier
,
Version
,
ctx
)
if
err
==
accounts
.
ErrNoKeys
{
utils
.
Fatalf
(
`No accounts configured.
Please run 'ethereum account new' to create a new account.`
)
}
else
if
err
!=
nil
{
if
err
!=
nil
{
utils
.
Fatalf
(
"%v"
,
err
)
}
...
...
@@ -172,10 +168,7 @@ Please run 'ethereum account new' to create a new account.`)
func
runjs
(
ctx
*
cli
.
Context
)
{
eth
,
err
:=
utils
.
GetEthereum
(
ClientIdentifier
,
Version
,
ctx
)
if
err
==
accounts
.
ErrNoKeys
{
utils
.
Fatalf
(
`No accounts configured.
Please run 'ethereum account new' to create a new account.`
)
}
else
if
err
!=
nil
{
if
err
!=
nil
{
utils
.
Fatalf
(
"%v"
,
err
)
}
...
...
@@ -214,7 +207,7 @@ func startEth(ctx *cli.Context, eth *eth.Ethereum) {
utils
.
StartRPC
(
eth
,
ctx
)
}
if
ctx
.
GlobalBool
(
utils
.
MiningEnabledFlag
.
Name
)
{
eth
.
Miner
()
.
Start
()
eth
.
StartMining
()
}
}
...
...
cmd/mist/assets/qml/views/miner.qml
View file @
6af078bd
...
...
@@ -55,8 +55,8 @@ Rectangle {
Button
{
text
:
"Start"
onClicked
:
{
eth
.
setGasPrice
(
minGasPrice
.
text
||
"10000000000000"
);
eth
.
setExtra
(
blockExtra
.
text
)
//
eth.setGasPrice(minGasPrice.text || "10000000000000");
//
eth.setExtra(blockExtra.text)
if
(
eth
.
toggleMining
())
{
this
.
text
=
"Stop"
;
}
else
{
...
...
@@ -65,35 +65,35 @@ Rectangle {
}
}
Rectangle
{
id
:
minGasPriceRect
anchors.top
:
parent
.
top
anchors.topMargin
:
2
width
:
200
TextField
{
id
:
minGasPrice
placeholderText
:
"Min Gas: 10000000000000"
width
:
200
validator
:
RegExpValidator
{
regExp
:
/
\d
*/
}
}
}
//
Rectangle {
//
id: minGasPriceRect
//
anchors.top: parent.top
//
anchors.topMargin: 2
//
width: 200
//
TextField {
//
id: minGasPrice
//
placeholderText: "Min Gas: 10000000000000"
//
width: 200
//
validator: RegExpValidator { regExp: /\d*/ }
//
}
//
}
Rectangle
{
width
:
300
anchors
{
left
:
minGasPriceRect
.
right
leftMargin
:
5
top
:
parent
.
top
topMargin
:
2
}
//
Rectangle {
//
width: 300
//
anchors {
//
left: minGasPriceRect.right
//
leftMargin: 5
//
top: parent.top
//
topMargin: 2
//
}
TextField
{
id
:
blockExtra
placeholderText
:
"Extra"
width
:
parent
.
width
maximumLength
:
1024
}
}
//
TextField {
//
id: blockExtra
//
placeholderText: "Extra"
//
width: parent.width
//
maximumLength: 1024
//
}
//
}
}
}
...
...
cmd/mist/assets/qml/views/network.qml
View file @
6af078bd
...
...
@@ -93,7 +93,6 @@ Rectangle {
// Check if it's mining and set it accordingly
if
(
miningSliderValue
>
0
&&
!
eth
.
miner
().
mining
())
{
// If the
eth
.
setGasPrice
(
"10000000000000"
);
eth
.
miner
().
start
();
}
else
if
(
miningSliderValue
==
0
&&
eth
.
miner
().
mining
())
{
eth
.
miner
().
stop
();
...
...
cmd/mist/ui_lib.go
View file @
6af078bd
...
...
@@ -175,22 +175,12 @@ func (self *UiLib) RemoveLocalTransaction(id int) {
//self.miner.RemoveLocalTx(id)
}
func
(
self
*
UiLib
)
SetGasPrice
(
price
string
)
{
self
.
Miner
()
.
MinAcceptedGasPrice
=
ethutil
.
Big
(
price
)
}
func
(
self
*
UiLib
)
SetExtra
(
extra
string
)
{
self
.
Miner
()
.
Extra
=
extra
}
func
(
self
*
UiLib
)
ToggleMining
()
bool
{
if
!
self
.
Miner
()
.
Mining
()
{
self
.
Miner
()
.
Start
()
return
true
if
!
self
.
eth
.
IsMining
()
{
err
:=
self
.
eth
.
StartMining
()
return
err
==
nil
}
else
{
self
.
Miner
()
.
Stop
()
self
.
eth
.
StopMining
()
return
false
}
}
...
...
eth/backend.go
View file @
6af078bd
...
...
@@ -166,18 +166,13 @@ func New(config *Config) (*Ethereum, error) {
DataDir
:
config
.
DataDir
,
}
cb
,
err
:=
eth
.
accountManager
.
Coinbase
()
if
err
!=
nil
{
return
nil
,
err
}
eth
.
chainManager
=
core
.
NewChainManager
(
blockDb
,
stateDb
,
eth
.
EventMux
())
pow
:=
ethash
.
New
(
eth
.
chainManager
)
eth
.
txPool
=
core
.
NewTxPool
(
eth
.
EventMux
())
eth
.
blockProcessor
=
core
.
NewBlockProcessor
(
stateDb
,
pow
,
eth
.
txPool
,
eth
.
chainManager
,
eth
.
EventMux
())
eth
.
chainManager
.
SetProcessor
(
eth
.
blockProcessor
)
eth
.
whisper
=
whisper
.
New
()
eth
.
miner
=
miner
.
New
(
cb
,
eth
,
pow
,
config
.
MinerThreads
)
eth
.
miner
=
miner
.
New
(
eth
,
pow
,
config
.
MinerThreads
)
hasBlock
:=
eth
.
chainManager
.
HasBlock
insertChain
:=
eth
.
chainManager
.
InsertChain
...
...
@@ -211,6 +206,19 @@ func New(config *Config) (*Ethereum, error) {
return
eth
,
nil
}
func
(
s
*
Ethereum
)
StartMining
()
error
{
cb
,
err
:=
s
.
accountManager
.
Coinbase
()
if
err
!=
nil
{
servlogger
.
Errorf
(
"Cannot start mining without coinbase: %v
\n
"
,
err
)
return
fmt
.
Errorf
(
"no coinbase: %v"
,
err
)
}
s
.
miner
.
Start
(
cb
)
return
nil
}
func
(
s
*
Ethereum
)
StopMining
()
{
s
.
miner
.
Stop
()
}
func
(
s
*
Ethereum
)
IsMining
()
bool
{
return
s
.
miner
.
Mining
()
}
func
(
s
*
Ethereum
)
Logger
()
logger
.
LogSystem
{
return
s
.
logger
}
func
(
s
*
Ethereum
)
Name
()
string
{
return
s
.
net
.
Name
}
func
(
s
*
Ethereum
)
AccountManager
()
*
accounts
.
Manager
{
return
s
.
accountManager
}
...
...
@@ -222,7 +230,6 @@ func (s *Ethereum) Whisper() *whisper.Whisper { return s.whisper }
func
(
s
*
Ethereum
)
EventMux
()
*
event
.
TypeMux
{
return
s
.
eventMux
}
func
(
s
*
Ethereum
)
BlockDb
()
ethutil
.
Database
{
return
s
.
blockDb
}
func
(
s
*
Ethereum
)
StateDb
()
ethutil
.
Database
{
return
s
.
stateDb
}
func
(
s
*
Ethereum
)
Miner
()
*
miner
.
Miner
{
return
s
.
miner
}
func
(
s
*
Ethereum
)
IsListening
()
bool
{
return
true
}
// Always listening
func
(
s
*
Ethereum
)
PeerCount
()
int
{
return
s
.
net
.
PeerCount
()
}
func
(
s
*
Ethereum
)
Peers
()
[]
*
p2p
.
Peer
{
return
s
.
net
.
Peers
()
}
...
...
@@ -261,7 +268,7 @@ func (s *Ethereum) Start() error {
}
func
(
s
*
Ethereum
)
StartForTest
()
{
jsonlogger
.
LogJson
(
&
logger
.
LogStarting
{
jsonlogger
.
LogJson
(
&
logger
.
LogStarting
{
ClientString
:
s
.
net
.
Name
,
ProtocolVersion
:
ProtocolVersion
,
})
...
...
miner/miner.go
View file @
6af078bd
...
...
@@ -17,44 +17,34 @@ type Miner struct {
MinAcceptedGasPrice
*
big
.
Int
Extra
string
Coinbase
[]
byte
mining
bool
pow
pow
.
PoW
mining
bool
eth
core
.
Backend
pow
pow
.
PoW
}
func
New
(
coinbase
[]
byte
,
eth
core
.
Backend
,
pow
pow
.
PoW
,
minerThreads
int
)
*
Miner
{
miner
:=
&
Miner
{
Coinbase
:
coinbase
,
worker
:
newWorker
(
coinbase
,
eth
),
pow
:
pow
,
}
minerThreads
=
1
for
i
:=
0
;
i
<
minerThreads
;
i
++
{
miner
.
worker
.
register
(
NewCpuMiner
(
i
,
miner
.
pow
))
}
return
miner
func
New
(
eth
core
.
Backend
,
pow
pow
.
PoW
,
minerThreads
int
)
*
Miner
{
// note: minerThreads is currently ignored because
// ethash is not thread safe.
return
&
Miner
{
eth
:
eth
,
pow
:
pow
}
}
func
(
self
*
Miner
)
Mining
()
bool
{
return
self
.
mining
}
func
(
self
*
Miner
)
Start
()
{
func
(
self
*
Miner
)
Start
(
coinbase
[]
byte
)
{
self
.
mining
=
true
self
.
worker
=
newWorker
(
coinbase
,
self
.
eth
)
self
.
worker
.
register
(
NewCpuMiner
(
0
,
self
.
pow
))
self
.
pow
.
(
*
ethash
.
Ethash
)
.
UpdateDAG
()
self
.
worker
.
start
()
self
.
worker
.
commitNewWork
()
}
func
(
self
*
Miner
)
Stop
()
{
self
.
mining
=
false
self
.
worker
.
stop
()
//self.pow.(*ethash.Ethash).Stop()
...
...
xeth/xeth.go
View file @
6af078bd
...
...
@@ -14,7 +14,6 @@ import (
"github.com/ethereum/go-ethereum/ethutil"
"github.com/ethereum/go-ethereum/event"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/miner"
"github.com/ethereum/go-ethereum/p2p"
"github.com/ethereum/go-ethereum/state"
"github.com/ethereum/go-ethereum/whisper"
...
...
@@ -35,7 +34,10 @@ type Backend interface {
StateDb
()
ethutil
.
Database
EventMux
()
*
event
.
TypeMux
Whisper
()
*
whisper
.
Whisper
Miner
()
*
miner
.
Miner
IsMining
()
bool
StartMining
()
error
StopMining
()
}
// Frontend should be implemented by users of XEth. Its methods are
...
...
@@ -65,7 +67,6 @@ type XEth struct {
accountManager
*
accounts
.
Manager
state
*
State
whisper
*
Whisper
miner
*
miner
.
Miner
frontend
Frontend
}
...
...
@@ -87,7 +88,6 @@ func New(eth Backend, frontend Frontend) *XEth {
chainManager
:
eth
.
ChainManager
(),
accountManager
:
eth
.
AccountManager
(),
whisper
:
NewWhisper
(
eth
.
Whisper
()),
miner
:
eth
.
Miner
(),
frontend
:
frontend
,
}
if
frontend
==
nil
{
...
...
@@ -104,7 +104,6 @@ func (self *XEth) WithState(statedb *state.StateDB) *XEth {
blockProcessor
:
self
.
blockProcessor
,
chainManager
:
self
.
chainManager
,
whisper
:
self
.
whisper
,
miner
:
self
.
miner
,
}
xeth
.
state
=
NewState
(
xeth
,
statedb
)
...
...
@@ -112,8 +111,7 @@ func (self *XEth) WithState(statedb *state.StateDB) *XEth {
}
func
(
self
*
XEth
)
State
()
*
State
{
return
self
.
state
}
func
(
self
*
XEth
)
Whisper
()
*
Whisper
{
return
self
.
whisper
}
func
(
self
*
XEth
)
Miner
()
*
miner
.
Miner
{
return
self
.
miner
}
func
(
self
*
XEth
)
Whisper
()
*
Whisper
{
return
self
.
whisper
}
func
(
self
*
XEth
)
BlockByHash
(
strHash
string
)
*
Block
{
hash
:=
fromHex
(
strHash
)
...
...
@@ -172,18 +170,19 @@ func (self *XEth) PeerCount() int {
}
func
(
self
*
XEth
)
IsMining
()
bool
{
return
self
.
miner
.
Mining
()
return
self
.
eth
.
Is
Mining
()
}
func
(
self
*
XEth
)
SetMining
(
shouldmine
bool
)
bool
{
ismining
:=
self
.
miner
.
Mining
()
ismining
:=
self
.
eth
.
Is
Mining
()
if
shouldmine
&&
!
ismining
{
self
.
miner
.
Start
()
err
:=
self
.
eth
.
StartMining
()
return
err
==
nil
}
if
ismining
&&
!
shouldmine
{
self
.
miner
.
Stop
()
self
.
eth
.
StopMining
()
}
return
self
.
miner
.
Mining
()
return
self
.
eth
.
Is
Mining
()
}
func
(
self
*
XEth
)
IsListening
()
bool
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment