Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
whqwjb
go-ethereum
提交
c705aac8
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 搜索 >>
未验证
提交
c705aac8
编写于
7月 10, 2019
作者:
P
Péter Szilágyi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
cmd, eth, les: make les flags conform to dotted style
上级
c6a9616c
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
79 addition
and
56 deletion
+79
-56
cmd/geth/main.go
cmd/geth/main.go
+7
-5
cmd/geth/usage.go
cmd/geth/usage.go
+7
-5
cmd/utils/flags.go
cmd/utils/flags.go
+47
-28
eth/config.go
eth/config.go
+4
-4
eth/gen_config.go
eth/gen_config.go
+10
-10
les/costtracker.go
les/costtracker.go
+4
-4
未找到文件。
cmd/geth/main.go
浏览文件 @
c705aac8
...
...
@@ -93,10 +93,12 @@ var (
utils
.
SyncModeFlag
,
utils
.
ExitWhenSyncedFlag
,
utils
.
GCModeFlag
,
utils
.
LightServFlag
,
utils
.
LightBandwidthInFlag
,
utils
.
LightBandwidthOutFlag
,
utils
.
LightPeersFlag
,
utils
.
LightServeFlag
,
utils
.
LightLegacyServFlag
,
utils
.
LightIngressFlag
,
utils
.
LightEgressFlag
,
utils
.
LightMaxPeersFlag
,
utils
.
LightLegacyPeersFlag
,
utils
.
LightKDFFlag
,
utils
.
UltraLightServersFlag
,
utils
.
UltraLightFractionFlag
,
...
...
@@ -336,7 +338,7 @@ func startNode(ctx *cli.Context, stack *node.Node) {
// Set contract backend for ethereum service if local node
// is serving LES requests.
if
ctx
.
GlobalInt
(
utils
.
Light
Serv
Flag
.
Name
)
>
0
{
if
ctx
.
GlobalInt
(
utils
.
Light
LegacyServFlag
.
Name
)
>
0
||
ctx
.
GlobalInt
(
utils
.
LightServe
Flag
.
Name
)
>
0
{
var
ethService
*
eth
.
Ethereum
if
err
:=
stack
.
Service
(
&
ethService
);
err
!=
nil
{
utils
.
Fatalf
(
"Failed to retrieve ethereum service: %v"
,
err
)
...
...
cmd/geth/usage.go
浏览文件 @
c705aac8
...
...
@@ -87,12 +87,12 @@ var AppHelpFlagGroups = []flagGroup{
},
},
{
Name
:
"L
ES
"
,
Name
:
"L
IGHT CLIENT
"
,
Flags
:
[]
cli
.
Flag
{
utils
.
LightServFlag
,
utils
.
Light
BandwidthIn
Flag
,
utils
.
Light
BandwidthOut
Flag
,
utils
.
LightPeersFlag
,
utils
.
LightServ
e
Flag
,
utils
.
Light
Ingress
Flag
,
utils
.
Light
Egress
Flag
,
utils
.
Light
Max
PeersFlag
,
utils
.
UltraLightServersFlag
,
utils
.
UltraLightFractionFlag
,
utils
.
UltraLightOnlyAnnounceFlag
,
...
...
@@ -253,6 +253,8 @@ var AppHelpFlagGroups = []flagGroup{
{
Name
:
"DEPRECATED"
,
Flags
:
[]
cli
.
Flag
{
utils
.
LightLegacyServFlag
,
utils
.
LightLegacyPeersFlag
,
utils
.
MinerLegacyThreadsFlag
,
utils
.
MinerLegacyGasTargetFlag
,
utils
.
MinerLegacyGasPriceFlag
,
...
...
cmd/utils/flags.go
浏览文件 @
c705aac8
...
...
@@ -209,25 +209,35 @@ var (
Name
:
"whitelist"
,
Usage
:
"Comma separated block number-to-hash mappings to enforce (<number>=<hash>)"
,
}
// L
ES
settings
Light
ServFlag
=
cli
.
IntFlag
{
// L
ight server and client
settings
Light
LegacyServFlag
=
cli
.
IntFlag
{
// Deprecated in favor of light.serve, remove in 2021
Name
:
"lightserv"
,
Usage
:
"Maximum percentage of time allowed for serving LES requests (deprecated, use --light.serve)"
,
Value
:
eth
.
DefaultConfig
.
LightServ
,
}
LightServeFlag
=
cli
.
IntFlag
{
Name
:
"light.serve"
,
Usage
:
"Maximum percentage of time allowed for serving LES requests (multi-threaded processing allows values over 100)"
,
Value
:
0
,
Value
:
eth
.
DefaultConfig
.
LightServ
,
}
Light
BandwidthIn
Flag
=
cli
.
IntFlag
{
Name
:
"light
bwin
"
,
Usage
:
"Incoming bandwidth limit for
light server
(kilobytes/sec, 0 = unlimited)"
,
Value
:
0
,
Light
Ingress
Flag
=
cli
.
IntFlag
{
Name
:
"light
.ingress
"
,
Usage
:
"Incoming bandwidth limit for
serving light clients
(kilobytes/sec, 0 = unlimited)"
,
Value
:
eth
.
DefaultConfig
.
LightIngress
,
}
Light
BandwidthOut
Flag
=
cli
.
IntFlag
{
Name
:
"light
bwout
"
,
Usage
:
"Outgoing bandwidth limit for
light server
(kilobytes/sec, 0 = unlimited)"
,
Value
:
0
,
Light
Egress
Flag
=
cli
.
IntFlag
{
Name
:
"light
.egress
"
,
Usage
:
"Outgoing bandwidth limit for
serving light clients
(kilobytes/sec, 0 = unlimited)"
,
Value
:
eth
.
DefaultConfig
.
LightEgress
,
}
Light
PeersFlag
=
cli
.
IntFlag
{
Light
LegacyPeersFlag
=
cli
.
IntFlag
{
// Deprecated in favor of light.maxpeers, remove in 2021
Name
:
"lightpeers"
,
Usage
:
"Maximum number of LES client peers"
,
Usage
:
"Maximum number of light clients to serve, or light servers to attach to (deprecated, use --light.maxpeers)"
,
Value
:
eth
.
DefaultConfig
.
LightPeers
,
}
LightMaxPeersFlag
=
cli
.
IntFlag
{
Name
:
"light.maxpeers"
,
Usage
:
"Maximum number of light clients to serve, or light servers to attach to"
,
Value
:
eth
.
DefaultConfig
.
LightPeers
,
}
UltraLightServersFlag
=
cli
.
StringFlag
{
...
...
@@ -952,17 +962,23 @@ func setIPC(ctx *cli.Context, cfg *node.Config) {
// setLes configures the les server and ultra light client settings from the command line flags.
func
setLes
(
ctx
*
cli
.
Context
,
cfg
*
eth
.
Config
)
{
if
ctx
.
GlobalIsSet
(
LightServFlag
.
Name
)
{
cfg
.
LightServ
=
ctx
.
GlobalInt
(
LightServFlag
.
Name
)
if
ctx
.
GlobalIsSet
(
LightLegacyServFlag
.
Name
)
{
cfg
.
LightServ
=
ctx
.
GlobalInt
(
LightLegacyServFlag
.
Name
)
}
if
ctx
.
GlobalIsSet
(
LightServeFlag
.
Name
)
{
cfg
.
LightServ
=
ctx
.
GlobalInt
(
LightServeFlag
.
Name
)
}
if
ctx
.
GlobalIsSet
(
LightIngressFlag
.
Name
)
{
cfg
.
LightIngress
=
ctx
.
GlobalInt
(
LightIngressFlag
.
Name
)
}
if
ctx
.
GlobalIsSet
(
Light
BandwidthIn
Flag
.
Name
)
{
cfg
.
Light
BandwidthIn
=
ctx
.
GlobalInt
(
LightBandwidthIn
Flag
.
Name
)
if
ctx
.
GlobalIsSet
(
Light
Egress
Flag
.
Name
)
{
cfg
.
Light
Egress
=
ctx
.
GlobalInt
(
LightEgress
Flag
.
Name
)
}
if
ctx
.
GlobalIsSet
(
Light
BandwidthOut
Flag
.
Name
)
{
cfg
.
Light
BandwidthOut
=
ctx
.
GlobalInt
(
LightBandwidthOut
Flag
.
Name
)
if
ctx
.
GlobalIsSet
(
Light
LegacyPeers
Flag
.
Name
)
{
cfg
.
Light
Peers
=
ctx
.
GlobalInt
(
LightLegacyPeers
Flag
.
Name
)
}
if
ctx
.
GlobalIsSet
(
LightPeersFlag
.
Name
)
{
cfg
.
LightPeers
=
ctx
.
GlobalInt
(
LightPeersFlag
.
Name
)
if
ctx
.
GlobalIsSet
(
Light
Max
PeersFlag
.
Name
)
{
cfg
.
LightPeers
=
ctx
.
GlobalInt
(
Light
Max
PeersFlag
.
Name
)
}
if
ctx
.
GlobalIsSet
(
UltraLightServersFlag
.
Name
)
{
cfg
.
UltraLightServers
=
strings
.
Split
(
ctx
.
GlobalString
(
UltraLightServersFlag
.
Name
),
","
)
...
...
@@ -1069,19 +1085,22 @@ func SetP2PConfig(ctx *cli.Context, cfg *p2p.Config) {
setBootstrapNodesV5
(
ctx
,
cfg
)
lightClient
:=
ctx
.
GlobalString
(
SyncModeFlag
.
Name
)
==
"light"
lightServer
:=
ctx
.
GlobalInt
(
LightServFlag
.
Name
)
!=
0
lightPeers
:=
ctx
.
GlobalInt
(
LightPeersFlag
.
Name
)
lightServer
:=
(
ctx
.
GlobalInt
(
LightLegacyServFlag
.
Name
)
!=
0
||
ctx
.
GlobalInt
(
LightServeFlag
.
Name
)
!=
0
)
lightPeers
:=
ctx
.
GlobalInt
(
LightLegacyPeersFlag
.
Name
)
if
ctx
.
GlobalIsSet
(
LightMaxPeersFlag
.
Name
)
{
lightPeers
=
ctx
.
GlobalInt
(
LightMaxPeersFlag
.
Name
)
}
if
ctx
.
GlobalIsSet
(
MaxPeersFlag
.
Name
)
{
cfg
.
MaxPeers
=
ctx
.
GlobalInt
(
MaxPeersFlag
.
Name
)
if
lightServer
&&
!
ctx
.
GlobalIsSet
(
LightPeersFlag
.
Name
)
{
if
lightServer
&&
!
ctx
.
GlobalIsSet
(
Light
LegacyPeersFlag
.
Name
)
&&
!
ctx
.
GlobalIsSet
(
LightMax
PeersFlag
.
Name
)
{
cfg
.
MaxPeers
+=
lightPeers
}
}
else
{
if
lightServer
{
cfg
.
MaxPeers
+=
lightPeers
}
if
lightClient
&&
ctx
.
GlobalIsSet
(
LightPeersFlag
.
Name
)
&&
cfg
.
MaxPeers
<
lightPeers
{
if
lightClient
&&
(
ctx
.
GlobalIsSet
(
LightLegacyPeersFlag
.
Name
)
||
ctx
.
GlobalIsSet
(
LightMaxPeersFlag
.
Name
)
)
&&
cfg
.
MaxPeers
<
lightPeers
{
cfg
.
MaxPeers
=
lightPeers
}
}
...
...
@@ -1379,9 +1398,9 @@ func SetShhConfig(ctx *cli.Context, stack *node.Node, cfg *whisper.Config) {
func
SetEthConfig
(
ctx
*
cli
.
Context
,
stack
*
node
.
Node
,
cfg
*
eth
.
Config
)
{
// Avoid conflicting network flags
CheckExclusive
(
ctx
,
DeveloperFlag
,
TestnetFlag
,
RinkebyFlag
,
GoerliFlag
)
CheckExclusive
(
ctx
,
Light
Serv
Flag
,
SyncModeFlag
,
"light"
)
// Can't use both ephemeral unlocked and external signer
CheckExclusive
(
ctx
,
DeveloperFlag
,
ExternalSignerFlag
)
CheckExclusive
(
ctx
,
Light
LegacyServFlag
,
LightServe
Flag
,
SyncModeFlag
,
"light"
)
CheckExclusive
(
ctx
,
DeveloperFlag
,
ExternalSignerFlag
)
// Can't use both ephemeral unlocked and external signer
var
ks
*
keystore
.
KeyStore
if
keystores
:=
stack
.
AccountManager
()
.
Backends
(
keystore
.
KeyStoreType
);
len
(
keystores
)
>
0
{
ks
=
keystores
[
0
]
.
(
*
keystore
.
KeyStore
)
...
...
eth/config.go
浏览文件 @
c705aac8
...
...
@@ -102,10 +102,10 @@ type Config struct {
Whitelist
map
[
uint64
]
common
.
Hash
`toml:"-"`
// Light client options
LightServ
int
`toml:",omitempty"`
// Maximum percentage of time allowed for serving LES requests
Light
BandwidthIn
int
`toml:",omitempty"`
// Incoming bandwidth limit for light servers
Light
BandwidthOut
int
`toml:",omitempty"`
// Outgoing bandwidth limit for light servers
LightPeers
int
`toml:",omitempty"`
// Maximum number of LES client peers
LightServ
int
`toml:",omitempty"`
// Maximum percentage of time allowed for serving LES requests
Light
Ingress
int
`toml:",omitempty"`
// Incoming bandwidth limit for light servers
Light
Egress
int
`toml:",omitempty"`
// Outgoing bandwidth limit for light servers
LightPeers
int
`toml:",omitempty"`
// Maximum number of LES client peers
// Ultra Light client options
UltraLightServers
[]
string
`toml:",omitempty"`
// List of trusted ultra light servers
...
...
eth/gen_config.go
浏览文件 @
c705aac8
...
...
@@ -25,8 +25,8 @@ func (c Config) MarshalTOML() (interface{}, error) {
NoPrefetch
bool
Whitelist
map
[
uint64
]
common
.
Hash
`toml:"-"`
LightServ
int
`toml:",omitempty"`
Light
BandwidthIn
int
`toml:",omitempty"`
Light
BandwidthOut
int
`toml:",omitempty"`
Light
Ingress
int
`toml:",omitempty"`
Light
Egress
int
`toml:",omitempty"`
LightPeers
int
`toml:",omitempty"`
UltraLightServers
[]
string
`toml:",omitempty"`
UltraLightFraction
int
`toml:",omitempty"`
...
...
@@ -58,8 +58,8 @@ func (c Config) MarshalTOML() (interface{}, error) {
enc
.
NoPrefetch
=
c
.
NoPrefetch
enc
.
Whitelist
=
c
.
Whitelist
enc
.
LightServ
=
c
.
LightServ
enc
.
Light
BandwidthIn
=
c
.
LightBandwidthIn
enc
.
Light
BandwidthOut
=
c
.
LightBandwidthOut
enc
.
Light
Ingress
=
c
.
LightIngress
enc
.
Light
Egress
=
c
.
LightEgress
enc
.
LightPeers
=
c
.
LightPeers
enc
.
UltraLightServers
=
c
.
UltraLightServers
enc
.
UltraLightFraction
=
c
.
UltraLightFraction
...
...
@@ -95,8 +95,8 @@ func (c *Config) UnmarshalTOML(unmarshal func(interface{}) error) error {
NoPrefetch
*
bool
Whitelist
map
[
uint64
]
common
.
Hash
`toml:"-"`
LightServ
*
int
`toml:",omitempty"`
Light
BandwidthIn
*
int
`toml:",omitempty"`
Light
BandwidthOut
*
int
`toml:",omitempty"`
Light
Ingress
*
int
`toml:",omitempty"`
Light
Egress
*
int
`toml:",omitempty"`
LightPeers
*
int
`toml:",omitempty"`
UltraLightServers
[]
string
`toml:",omitempty"`
UltraLightFraction
*
int
`toml:",omitempty"`
...
...
@@ -145,11 +145,11 @@ func (c *Config) UnmarshalTOML(unmarshal func(interface{}) error) error {
if
dec
.
LightServ
!=
nil
{
c
.
LightServ
=
*
dec
.
LightServ
}
if
dec
.
Light
BandwidthIn
!=
nil
{
c
.
Light
BandwidthIn
=
*
dec
.
LightBandwidthIn
if
dec
.
Light
Ingress
!=
nil
{
c
.
Light
Ingress
=
*
dec
.
LightIngress
}
if
dec
.
Light
BandwidthOut
!=
nil
{
c
.
Light
BandwidthOut
=
*
dec
.
LightBandwidthOut
if
dec
.
Light
Egress
!=
nil
{
c
.
Light
Egress
=
*
dec
.
LightEgress
}
if
dec
.
LightPeers
!=
nil
{
c
.
LightPeers
=
*
dec
.
LightPeers
...
...
les/costtracker.go
浏览文件 @
c705aac8
...
...
@@ -139,11 +139,11 @@ func newCostTracker(db ethdb.Database, config *eth.Config) (*costTracker, uint64
reqInfoCh
:
make
(
chan
reqInfo
,
100
),
utilTarget
:
utilTarget
,
}
if
config
.
Light
BandwidthIn
>
0
{
ct
.
inSizeFactor
=
utilTarget
/
float64
(
config
.
Light
BandwidthIn
)
if
config
.
Light
Ingress
>
0
{
ct
.
inSizeFactor
=
utilTarget
/
float64
(
config
.
Light
Ingress
)
}
if
config
.
Light
BandwidthOut
>
0
{
ct
.
outSizeFactor
=
utilTarget
/
float64
(
config
.
Light
BandwidthOut
)
if
config
.
Light
Egress
>
0
{
ct
.
outSizeFactor
=
utilTarget
/
float64
(
config
.
Light
Egress
)
}
if
makeCostStats
{
ct
.
stats
=
make
(
map
[
uint64
][]
uint64
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录