Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
whqwjb
go-ethereum
提交
80be5e54
G
go-ethereum
项目概览
whqwjb
/
go-ethereum
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
go-ethereum
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
80be5e54
编写于
10月 26, 2017
作者:
P
Péter Szilágyi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
cmd/puppeth: store genesis locally to persist restarts
上级
7abf968d
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
64 addition
and
49 deletion
+64
-49
cmd/puppeth/module_dashboard.go
cmd/puppeth/module_dashboard.go
+12
-12
cmd/puppeth/wizard.go
cmd/puppeth/wizard.go
+5
-5
cmd/puppeth/wizard_explorer.go
cmd/puppeth/wizard_explorer.go
+3
-3
cmd/puppeth/wizard_faucet.go
cmd/puppeth/wizard_faucet.go
+2
-2
cmd/puppeth/wizard_genesis.go
cmd/puppeth/wizard_genesis.go
+28
-13
cmd/puppeth/wizard_intro.go
cmd/puppeth/wizard_intro.go
+2
-2
cmd/puppeth/wizard_netstats.go
cmd/puppeth/wizard_netstats.go
+3
-3
cmd/puppeth/wizard_node.go
cmd/puppeth/wizard_node.go
+6
-6
cmd/puppeth/wizard_wallet.go
cmd/puppeth/wizard_wallet.go
+3
-3
未找到文件。
cmd/puppeth/module_dashboard.go
浏览文件 @
80be5e54
...
...
@@ -608,7 +608,7 @@ func deployDashboard(client *sshClient, network string, conf *config, config *da
}
template
.
Must
(
template
.
New
(
""
)
.
Parse
(
dashboardContent
))
.
Execute
(
indexfile
,
map
[
string
]
interface
{}{
"Network"
:
network
,
"NetworkID"
:
conf
.
g
enesis
.
Config
.
ChainId
,
"NetworkID"
:
conf
.
G
enesis
.
Config
.
ChainId
,
"NetworkTitle"
:
strings
.
Title
(
network
),
"EthstatsPage"
:
config
.
ethstats
,
"ExplorerPage"
:
config
.
explorer
,
...
...
@@ -620,7 +620,7 @@ func deployDashboard(client *sshClient, network string, conf *config, config *da
"BootnodesFullFlat"
:
strings
.
Join
(
conf
.
bootFull
,
","
),
"BootnodesLightFlat"
:
strings
.
Join
(
conf
.
bootLight
,
","
),
"Ethstats"
:
statsLogin
,
"Ethash"
:
conf
.
g
enesis
.
Config
.
Ethash
!=
nil
,
"Ethash"
:
conf
.
G
enesis
.
Config
.
Ethash
!=
nil
,
"CppGenesis"
:
network
+
"-cpp.json"
,
"CppBootnodes"
:
strings
.
Join
(
bootCpp
,
" "
),
"HarmonyGenesis"
:
network
+
"-harmony.json"
,
...
...
@@ -628,36 +628,36 @@ func deployDashboard(client *sshClient, network string, conf *config, config *da
"ParityGenesis"
:
network
+
"-parity.json"
,
"PythonGenesis"
:
network
+
"-python.json"
,
"PythonBootnodes"
:
strings
.
Join
(
bootPython
,
","
),
"Homestead"
:
conf
.
g
enesis
.
Config
.
HomesteadBlock
,
"Tangerine"
:
conf
.
g
enesis
.
Config
.
EIP150Block
,
"Spurious"
:
conf
.
g
enesis
.
Config
.
EIP155Block
,
"Byzantium"
:
conf
.
g
enesis
.
Config
.
ByzantiumBlock
,
"Homestead"
:
conf
.
G
enesis
.
Config
.
HomesteadBlock
,
"Tangerine"
:
conf
.
G
enesis
.
Config
.
EIP150Block
,
"Spurious"
:
conf
.
G
enesis
.
Config
.
EIP155Block
,
"Byzantium"
:
conf
.
G
enesis
.
Config
.
ByzantiumBlock
,
})
files
[
filepath
.
Join
(
workdir
,
"index.html"
)]
=
indexfile
.
Bytes
()
// Marshal the genesis spec files for go-ethereum and all the other clients
genesis
,
_
:=
conf
.
g
enesis
.
MarshalJSON
()
genesis
,
_
:=
conf
.
G
enesis
.
MarshalJSON
()
files
[
filepath
.
Join
(
workdir
,
network
+
".json"
)]
=
genesis
if
conf
.
g
enesis
.
Config
.
Ethash
!=
nil
{
cppSpec
,
err
:=
newCppEthereumGenesisSpec
(
network
,
conf
.
g
enesis
)
if
conf
.
G
enesis
.
Config
.
Ethash
!=
nil
{
cppSpec
,
err
:=
newCppEthereumGenesisSpec
(
network
,
conf
.
G
enesis
)
if
err
!=
nil
{
return
nil
,
err
}
cppSpecJSON
,
_
:=
json
.
Marshal
(
cppSpec
)
files
[
filepath
.
Join
(
workdir
,
network
+
"-cpp.json"
)]
=
cppSpecJSON
harmonySpecJSON
,
_
:=
conf
.
g
enesis
.
MarshalJSON
()
harmonySpecJSON
,
_
:=
conf
.
G
enesis
.
MarshalJSON
()
files
[
filepath
.
Join
(
workdir
,
network
+
"-harmony.json"
)]
=
harmonySpecJSON
paritySpec
,
err
:=
newParityChainSpec
(
network
,
conf
.
g
enesis
,
conf
.
bootFull
)
paritySpec
,
err
:=
newParityChainSpec
(
network
,
conf
.
G
enesis
,
conf
.
bootFull
)
if
err
!=
nil
{
return
nil
,
err
}
paritySpecJSON
,
_
:=
json
.
Marshal
(
paritySpec
)
files
[
filepath
.
Join
(
workdir
,
network
+
"-parity.json"
)]
=
paritySpecJSON
pyethSpec
,
err
:=
newPyEthereumGenesisSpec
(
network
,
conf
.
g
enesis
)
pyethSpec
,
err
:=
newPyEthereumGenesisSpec
(
network
,
conf
.
G
enesis
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
cmd/puppeth/wizard.go
浏览文件 @
80be5e54
...
...
@@ -39,12 +39,12 @@ import (
// config contains all the configurations needed by puppeth that should be saved
// between sessions.
type
config
struct
{
path
string
// File containing the configuration values
genesis
*
core
.
Genesis
// Genesis block to cache for node deploys
bootFull
[]
string
// Bootnodes to always connect to by full nodes
bootLight
[]
string
// Bootnodes to always connect to by light nodes
ethstats
string
// Ethstats settings to cache for node deploys
path
string
// File containing the configuration values
bootFull
[]
string
// Bootnodes to always connect to by full nodes
bootLight
[]
string
// Bootnodes to always connect to by light nodes
ethstats
string
// Ethstats settings to cache for node deploys
Genesis
*
core
.
Genesis
`json:"genesis,omitempty"`
// Genesis block to cache for node deploys
Servers
map
[
string
][]
byte
`json:"servers,omitempty"`
}
...
...
cmd/puppeth/wizard_explorer.go
浏览文件 @
80be5e54
...
...
@@ -27,7 +27,7 @@ import (
// deployExplorer creates a new block explorer based on some user input.
func
(
w
*
wizard
)
deployExplorer
()
{
// Do some sanity check before the user wastes time on input
if
w
.
conf
.
g
enesis
==
nil
{
if
w
.
conf
.
G
enesis
==
nil
{
log
.
Error
(
"No genesis block configured"
)
return
}
...
...
@@ -35,7 +35,7 @@ func (w *wizard) deployExplorer() {
log
.
Error
(
"No ethstats server configured"
)
return
}
if
w
.
conf
.
g
enesis
.
Config
.
Ethash
==
nil
{
if
w
.
conf
.
G
enesis
.
Config
.
Ethash
==
nil
{
log
.
Error
(
"Only ethash network supported"
)
return
}
...
...
@@ -51,7 +51,7 @@ func (w *wizard) deployExplorer() {
if
err
!=
nil
{
infos
=
&
explorerInfos
{
nodePort
:
30303
,
webPort
:
80
,
webHost
:
client
.
server
}
}
chainspec
,
err
:=
newParityChainSpec
(
w
.
network
,
w
.
conf
.
g
enesis
,
w
.
conf
.
bootFull
)
chainspec
,
err
:=
newParityChainSpec
(
w
.
network
,
w
.
conf
.
G
enesis
,
w
.
conf
.
bootFull
)
if
err
!=
nil
{
log
.
Error
(
"Failed to create chain spec for explorer"
,
"err"
,
err
)
return
...
...
cmd/puppeth/wizard_faucet.go
浏览文件 @
80be5e54
...
...
@@ -47,8 +47,8 @@ func (w *wizard) deployFaucet() {
tiers
:
3
,
}
}
infos
.
node
.
genesis
,
_
=
json
.
MarshalIndent
(
w
.
conf
.
g
enesis
,
""
,
" "
)
infos
.
node
.
network
=
w
.
conf
.
g
enesis
.
Config
.
ChainId
.
Int64
()
infos
.
node
.
genesis
,
_
=
json
.
MarshalIndent
(
w
.
conf
.
G
enesis
,
""
,
" "
)
infos
.
node
.
network
=
w
.
conf
.
G
enesis
.
Config
.
ChainId
.
Int64
()
// Figure out which port to listen on
fmt
.
Println
()
...
...
cmd/puppeth/wizard_genesis.go
浏览文件 @
80be5e54
...
...
@@ -124,7 +124,10 @@ func (w *wizard) makeGenesis() {
genesis
.
Config
.
ChainId
=
new
(
big
.
Int
)
.
SetUint64
(
uint64
(
w
.
readDefaultInt
(
rand
.
Intn
(
65536
))))
// All done, store the genesis and flush to disk
w
.
conf
.
genesis
=
genesis
log
.
Info
(
"Configured new genesis block"
)
w
.
conf
.
Genesis
=
genesis
w
.
conf
.
flush
()
}
// manageGenesis permits the modification of chain configuration parameters in
...
...
@@ -134,44 +137,56 @@ func (w *wizard) manageGenesis() {
fmt
.
Println
()
fmt
.
Println
(
" 1. Modify existing fork rules"
)
fmt
.
Println
(
" 2. Export genesis configuration"
)
fmt
.
Println
(
" 3. Remove genesis configuration"
)
choice
:=
w
.
read
()
switch
{
case
choice
==
"1"
:
// Fork rule updating requested, iterate over each fork
fmt
.
Println
()
fmt
.
Printf
(
"Which block should Homestead come into effect? (default = %v)
\n
"
,
w
.
conf
.
g
enesis
.
Config
.
HomesteadBlock
)
w
.
conf
.
genesis
.
Config
.
HomesteadBlock
=
w
.
readDefaultBigInt
(
w
.
conf
.
g
enesis
.
Config
.
HomesteadBlock
)
fmt
.
Printf
(
"Which block should Homestead come into effect? (default = %v)
\n
"
,
w
.
conf
.
G
enesis
.
Config
.
HomesteadBlock
)
w
.
conf
.
Genesis
.
Config
.
HomesteadBlock
=
w
.
readDefaultBigInt
(
w
.
conf
.
G
enesis
.
Config
.
HomesteadBlock
)
fmt
.
Println
()
fmt
.
Printf
(
"Which block should EIP150 come into effect? (default = %v)
\n
"
,
w
.
conf
.
g
enesis
.
Config
.
EIP150Block
)
w
.
conf
.
genesis
.
Config
.
EIP150Block
=
w
.
readDefaultBigInt
(
w
.
conf
.
g
enesis
.
Config
.
EIP150Block
)
fmt
.
Printf
(
"Which block should EIP150 come into effect? (default = %v)
\n
"
,
w
.
conf
.
G
enesis
.
Config
.
EIP150Block
)
w
.
conf
.
Genesis
.
Config
.
EIP150Block
=
w
.
readDefaultBigInt
(
w
.
conf
.
G
enesis
.
Config
.
EIP150Block
)
fmt
.
Println
()
fmt
.
Printf
(
"Which block should EIP155 come into effect? (default = %v)
\n
"
,
w
.
conf
.
g
enesis
.
Config
.
EIP155Block
)
w
.
conf
.
genesis
.
Config
.
EIP155Block
=
w
.
readDefaultBigInt
(
w
.
conf
.
g
enesis
.
Config
.
EIP155Block
)
fmt
.
Printf
(
"Which block should EIP155 come into effect? (default = %v)
\n
"
,
w
.
conf
.
G
enesis
.
Config
.
EIP155Block
)
w
.
conf
.
Genesis
.
Config
.
EIP155Block
=
w
.
readDefaultBigInt
(
w
.
conf
.
G
enesis
.
Config
.
EIP155Block
)
fmt
.
Println
()
fmt
.
Printf
(
"Which block should EIP158 come into effect? (default = %v)
\n
"
,
w
.
conf
.
g
enesis
.
Config
.
EIP158Block
)
w
.
conf
.
genesis
.
Config
.
EIP158Block
=
w
.
readDefaultBigInt
(
w
.
conf
.
g
enesis
.
Config
.
EIP158Block
)
fmt
.
Printf
(
"Which block should EIP158 come into effect? (default = %v)
\n
"
,
w
.
conf
.
G
enesis
.
Config
.
EIP158Block
)
w
.
conf
.
Genesis
.
Config
.
EIP158Block
=
w
.
readDefaultBigInt
(
w
.
conf
.
G
enesis
.
Config
.
EIP158Block
)
fmt
.
Println
()
fmt
.
Printf
(
"Which block should Byzantium come into effect? (default = %v)
\n
"
,
w
.
conf
.
g
enesis
.
Config
.
ByzantiumBlock
)
w
.
conf
.
genesis
.
Config
.
ByzantiumBlock
=
w
.
readDefaultBigInt
(
w
.
conf
.
g
enesis
.
Config
.
ByzantiumBlock
)
fmt
.
Printf
(
"Which block should Byzantium come into effect? (default = %v)
\n
"
,
w
.
conf
.
G
enesis
.
Config
.
ByzantiumBlock
)
w
.
conf
.
Genesis
.
Config
.
ByzantiumBlock
=
w
.
readDefaultBigInt
(
w
.
conf
.
G
enesis
.
Config
.
ByzantiumBlock
)
out
,
_
:=
json
.
MarshalIndent
(
w
.
conf
.
g
enesis
.
Config
,
""
,
" "
)
out
,
_
:=
json
.
MarshalIndent
(
w
.
conf
.
G
enesis
.
Config
,
""
,
" "
)
fmt
.
Printf
(
"Chain configuration updated:
\n\n
%s
\n
"
,
out
)
case
choice
==
"2"
:
// Save whatever genesis configuration we currently have
fmt
.
Println
()
fmt
.
Printf
(
"Which file to save the genesis into? (default = %s.json)
\n
"
,
w
.
network
)
out
,
_
:=
json
.
MarshalIndent
(
w
.
conf
.
g
enesis
,
""
,
" "
)
out
,
_
:=
json
.
MarshalIndent
(
w
.
conf
.
G
enesis
,
""
,
" "
)
if
err
:=
ioutil
.
WriteFile
(
w
.
readDefaultString
(
fmt
.
Sprintf
(
"%s.json"
,
w
.
network
)),
out
,
0644
);
err
!=
nil
{
log
.
Error
(
"Failed to save genesis file"
,
"err"
,
err
)
}
log
.
Info
(
"Exported existing genesis block"
)
case
choice
==
"3"
:
// Make sure we don't have any services running
if
len
(
w
.
conf
.
servers
())
>
0
{
log
.
Error
(
"Genesis reset requires all services and servers torn down"
)
return
}
log
.
Info
(
"Genesis block destroyed"
)
w
.
conf
.
Genesis
=
nil
w
.
conf
.
flush
()
default
:
log
.
Error
(
"That's not something I can do"
)
}
...
...
cmd/puppeth/wizard_intro.go
浏览文件 @
80be5e54
...
...
@@ -107,7 +107,7 @@ func (w *wizard) run() {
fmt
.
Println
()
fmt
.
Println
(
"What would you like to do? (default = stats)"
)
fmt
.
Println
(
" 1. Show network stats"
)
if
w
.
conf
.
g
enesis
==
nil
{
if
w
.
conf
.
G
enesis
==
nil
{
fmt
.
Println
(
" 2. Configure new genesis"
)
}
else
{
fmt
.
Println
(
" 2. Manage existing genesis"
)
...
...
@@ -129,7 +129,7 @@ func (w *wizard) run() {
w
.
networkStats
()
case
choice
==
"2"
:
if
w
.
conf
.
g
enesis
==
nil
{
if
w
.
conf
.
G
enesis
==
nil
{
w
.
makeGenesis
()
}
else
{
w
.
manageGenesis
()
...
...
cmd/puppeth/wizard_netstats.go
浏览文件 @
80be5e54
...
...
@@ -32,7 +32,7 @@ import (
// configuration set to give users hints on how to do various tasks.
func
(
w
*
wizard
)
networkStats
()
{
if
len
(
w
.
servers
)
==
0
{
log
.
Error
(
"No remote machines to gather stats from"
)
log
.
Info
(
"No remote machines to gather stats from"
)
return
}
// Clear out some previous configs to refill from current scan
...
...
@@ -173,12 +173,12 @@ func (w *wizard) gatherStats(server string, pubkey []byte, client *sshClient) *s
w
.
lock
.
Lock
()
defer
w
.
lock
.
Unlock
()
if
genesis
!=
""
&&
w
.
conf
.
g
enesis
==
nil
{
if
genesis
!=
""
&&
w
.
conf
.
G
enesis
==
nil
{
g
:=
new
(
core
.
Genesis
)
if
err
:=
json
.
Unmarshal
([]
byte
(
genesis
),
g
);
err
!=
nil
{
log
.
Error
(
"Failed to parse remote genesis"
,
"err"
,
err
)
}
else
{
w
.
conf
.
g
enesis
=
g
w
.
conf
.
G
enesis
=
g
}
}
if
ethstats
!=
""
{
...
...
cmd/puppeth/wizard_node.go
浏览文件 @
80be5e54
...
...
@@ -29,7 +29,7 @@ import (
// deployNode creates a new node configuration based on some user input.
func
(
w
*
wizard
)
deployNode
(
boot
bool
)
{
// Do some sanity check before the user wastes time on input
if
w
.
conf
.
g
enesis
==
nil
{
if
w
.
conf
.
G
enesis
==
nil
{
log
.
Error
(
"No genesis block configured"
)
return
}
...
...
@@ -53,8 +53,8 @@ func (w *wizard) deployNode(boot bool) {
infos
=
&
nodeInfos
{
portFull
:
30303
,
peersTotal
:
50
,
peersLight
:
0
,
gasTarget
:
4.7
,
gasPrice
:
18
}
}
}
infos
.
genesis
,
_
=
json
.
MarshalIndent
(
w
.
conf
.
g
enesis
,
""
,
" "
)
infos
.
network
=
w
.
conf
.
g
enesis
.
Config
.
ChainId
.
Int64
()
infos
.
genesis
,
_
=
json
.
MarshalIndent
(
w
.
conf
.
G
enesis
,
""
,
" "
)
infos
.
network
=
w
.
conf
.
G
enesis
.
Config
.
ChainId
.
Int64
()
// Figure out where the user wants to store the persistent data
fmt
.
Println
()
...
...
@@ -65,7 +65,7 @@ func (w *wizard) deployNode(boot bool) {
fmt
.
Printf
(
"Where should data be stored on the remote machine? (default = %s)
\n
"
,
infos
.
datadir
)
infos
.
datadir
=
w
.
readDefaultString
(
infos
.
datadir
)
}
if
w
.
conf
.
g
enesis
.
Config
.
Ethash
!=
nil
&&
!
boot
{
if
w
.
conf
.
G
enesis
.
Config
.
Ethash
!=
nil
&&
!
boot
{
fmt
.
Println
()
if
infos
.
ethashdir
==
""
{
fmt
.
Printf
(
"Where should the ethash mining DAGs be stored on the remote machine?
\n
"
)
...
...
@@ -101,7 +101,7 @@ func (w *wizard) deployNode(boot bool) {
}
// If the node is a miner/signer, load up needed credentials
if
!
boot
{
if
w
.
conf
.
g
enesis
.
Config
.
Ethash
!=
nil
{
if
w
.
conf
.
G
enesis
.
Config
.
Ethash
!=
nil
{
// Ethash based miners only need an etherbase to mine against
fmt
.
Println
()
if
infos
.
etherbase
==
""
{
...
...
@@ -116,7 +116,7 @@ func (w *wizard) deployNode(boot bool) {
fmt
.
Printf
(
"What address should the miner user? (default = %s)
\n
"
,
infos
.
etherbase
)
infos
.
etherbase
=
w
.
readDefaultAddress
(
common
.
HexToAddress
(
infos
.
etherbase
))
.
Hex
()
}
}
else
if
w
.
conf
.
g
enesis
.
Config
.
Clique
!=
nil
{
}
else
if
w
.
conf
.
G
enesis
.
Config
.
Clique
!=
nil
{
// If a previous signer was already set, offer to reuse it
if
infos
.
keyJSON
!=
""
{
if
key
,
err
:=
keystore
.
DecryptKey
([]
byte
(
infos
.
keyJSON
),
infos
.
keyPass
);
err
!=
nil
{
...
...
cmd/puppeth/wizard_wallet.go
浏览文件 @
80be5e54
...
...
@@ -27,7 +27,7 @@ import (
// deployWallet creates a new web wallet based on some user input.
func
(
w
*
wizard
)
deployWallet
()
{
// Do some sanity check before the user wastes time on input
if
w
.
conf
.
g
enesis
==
nil
{
if
w
.
conf
.
G
enesis
==
nil
{
log
.
Error
(
"No genesis block configured"
)
return
}
...
...
@@ -47,8 +47,8 @@ func (w *wizard) deployWallet() {
if
err
!=
nil
{
infos
=
&
walletInfos
{
nodePort
:
30303
,
rpcPort
:
8545
,
webPort
:
80
,
webHost
:
client
.
server
}
}
infos
.
genesis
,
_
=
json
.
MarshalIndent
(
w
.
conf
.
g
enesis
,
""
,
" "
)
infos
.
network
=
w
.
conf
.
g
enesis
.
Config
.
ChainId
.
Int64
()
infos
.
genesis
,
_
=
json
.
MarshalIndent
(
w
.
conf
.
G
enesis
,
""
,
" "
)
infos
.
network
=
w
.
conf
.
G
enesis
.
Config
.
ChainId
.
Int64
()
// Figure out which port to listen on
fmt
.
Println
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录