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
0b4b2b81
Commit
0b4b2b81
authored
Mar 27, 2015
by
Jeffrey Wilcke
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #580 from ethersphere/frontier/cli-key
settable etherbase
parents
54a14d5c
b375bbee
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
37 additions
and
18 deletions
+37
-18
account_manager.go
accounts/account_manager.go
+1
-7
main.go
cmd/geth/main.go
+4
-4
flags.go
cmd/utils/flags.go
+7
-1
backend.go
eth/backend.go
+23
-4
xeth.go
xeth/xeth.go
+2
-2
No files found.
accounts/account_manager.go
View file @
0b4b2b81
...
...
@@ -81,13 +81,7 @@ func (am *Manager) HasAccount(addr []byte) bool {
return
false
}
// Coinbase returns the account address that mining rewards are sent to.
func
(
am
*
Manager
)
Coinbase
()
(
addr
[]
byte
,
err
error
)
{
// TODO: persist coinbase address on disk
return
am
.
firstAddr
()
}
func
(
am
*
Manager
)
firstAddr
()
([]
byte
,
error
)
{
func
(
am
*
Manager
)
Primary
()
(
addr
[]
byte
,
err
error
)
{
addrs
,
err
:=
am
.
keyStore
.
GetKeyAddresses
()
if
os
.
IsNotExist
(
err
)
{
return
nil
,
ErrNoKeys
...
...
cmd/geth/main.go
View file @
0b4b2b81
...
...
@@ -221,6 +221,7 @@ JavaScript API. See https://github.com/ethereum/go-ethereum/wiki/Javascipt-Conso
utils
.
LogJSONFlag
,
utils
.
LogLevelFlag
,
utils
.
MaxPeersFlag
,
utils
.
EtherbaseFlag
,
utils
.
MinerThreadsFlag
,
utils
.
MiningEnabledFlag
,
utils
.
NATFlag
,
...
...
@@ -322,10 +323,10 @@ func startEth(ctx *cli.Context, eth *eth.Ethereum) {
account
:=
ctx
.
GlobalString
(
utils
.
UnlockedAccountFlag
.
Name
)
if
len
(
account
)
>
0
{
if
account
==
"
coinbase
"
{
accbytes
,
err
:=
am
.
Coinbase
()
if
account
==
"
primary
"
{
accbytes
,
err
:=
am
.
Primary
()
if
err
!=
nil
{
utils
.
Fatalf
(
"no
coinbase
account: %v"
,
err
)
utils
.
Fatalf
(
"no
primary
account: %v"
,
err
)
}
account
=
common
.
ToHex
(
accbytes
)
}
...
...
@@ -468,7 +469,6 @@ func dump(ctx *cli.Context) {
}
else
{
statedb
:=
state
.
New
(
block
.
Root
(),
stateDb
)
fmt
.
Printf
(
"%s
\n
"
,
statedb
.
Dump
())
// fmt.Println(block)
}
}
}
...
...
cmd/utils/flags.go
View file @
0b4b2b81
...
...
@@ -96,10 +96,15 @@ var (
Name
:
"mine"
,
Usage
:
"Enable mining"
,
}
EtherbaseFlag
=
cli
.
StringFlag
{
Name
:
"Etherbase"
,
Usage
:
"public address for block mining rewards. By default the address of your primary account is used"
,
Value
:
"primary"
,
}
UnlockedAccountFlag
=
cli
.
StringFlag
{
Name
:
"unlock"
,
Usage
:
"unlock the account given until this program exits (prompts for password). '--unlock
coinbase' unlocks the primary (coinbase)
account"
,
Usage
:
"unlock the account given until this program exits (prompts for password). '--unlock
primary' unlocks the primary
account"
,
Value
:
""
,
}
PasswordFileFlag
=
cli
.
StringFlag
{
...
...
@@ -215,6 +220,7 @@ func MakeEthConfig(clientID, version string, ctx *cli.Context) *eth.Config {
LogFile
:
ctx
.
GlobalString
(
LogFileFlag
.
Name
),
LogLevel
:
ctx
.
GlobalInt
(
LogLevelFlag
.
Name
),
LogJSON
:
ctx
.
GlobalString
(
LogJSONFlag
.
Name
),
Etherbase
:
ctx
.
GlobalString
(
EtherbaseFlag
.
Name
),
MinerThreads
:
ctx
.
GlobalInt
(
MinerThreadsFlag
.
Name
),
AccountManager
:
GetAccountManager
(
ctx
),
VmDebug
:
ctx
.
GlobalBool
(
VMDebugFlag
.
Name
),
...
...
eth/backend.go
View file @
0b4b2b81
...
...
@@ -63,6 +63,7 @@ type Config struct {
Shh
bool
Dial
bool
Etherbase
string
MinerThreads
int
AccountManager
*
accounts
.
Manager
...
...
@@ -140,6 +141,7 @@ type Ethereum struct {
Mining
bool
DataDir
string
etherbase
common
.
Address
clientVersion
string
ethVersionId
int
netVersionId
int
...
...
@@ -185,6 +187,7 @@ func New(config *Config) (*Ethereum, error) {
eventMux
:
&
event
.
TypeMux
{},
accountManager
:
config
.
AccountManager
,
DataDir
:
config
.
DataDir
,
etherbase
:
common
.
HexToAddress
(
config
.
Etherbase
),
clientVersion
:
config
.
Name
,
// TODO should separate from Name
ethVersionId
:
config
.
ProtocolVersion
,
netVersionId
:
config
.
NetworkId
,
...
...
@@ -297,15 +300,31 @@ func (s *Ethereum) ResetWithGenesisBlock(gb *types.Block) {
}
func
(
s
*
Ethereum
)
StartMining
()
error
{
cb
,
err
:=
s
.
accountManager
.
Coin
base
()
eb
,
err
:=
s
.
Ether
base
()
if
err
!=
nil
{
servlogger
.
Errorf
(
"Cannot start mining without coinbase: %v
\n
"
,
err
)
return
fmt
.
Errorf
(
"no coinbase: %v"
,
err
)
err
=
fmt
.
Errorf
(
"Cannot start mining without etherbase address: %v"
,
err
)
servlogger
.
Errorln
(
err
)
return
err
}
s
.
miner
.
Start
(
common
.
BytesToAddress
(
cb
))
s
.
miner
.
Start
(
eb
)
return
nil
}
func
(
s
*
Ethereum
)
Etherbase
()
(
eb
common
.
Address
,
err
error
)
{
eb
=
s
.
etherbase
if
(
eb
==
common
.
Address
{})
{
var
ebbytes
[]
byte
ebbytes
,
err
=
s
.
accountManager
.
Primary
()
eb
=
common
.
BytesToAddress
(
ebbytes
)
if
(
eb
==
common
.
Address
{})
{
err
=
fmt
.
Errorf
(
"no accounts found"
)
}
}
return
}
func
(
s
*
Ethereum
)
StopMining
()
{
s
.
miner
.
Stop
()
}
func
(
s
*
Ethereum
)
IsMining
()
bool
{
return
s
.
miner
.
Mining
()
}
func
(
s
*
Ethereum
)
Miner
()
*
miner
.
Miner
{
return
s
.
miner
}
...
...
xeth/xeth.go
View file @
0b4b2b81
...
...
@@ -260,8 +260,8 @@ func (self *XEth) IsListening() bool {
}
func
(
self
*
XEth
)
Coinbase
()
string
{
cb
,
_
:=
self
.
backend
.
AccountManager
()
.
Coin
base
()
return
common
.
ToHex
(
cb
)
eb
,
_
:=
self
.
backend
.
Ether
base
()
return
eb
.
Hex
(
)
}
func
(
self
*
XEth
)
NumberToHuman
(
balance
string
)
string
{
...
...
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