Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
whqwjb
go-ethereum
提交
e1a0ee8f
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 搜索 >>
提交
e1a0ee8f
编写于
5月 26, 2015
作者:
P
Péter Szilágyi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
cmd/geth, cmd/utils, eth, p2p: pass and honor a no discovery flag
上级
278183c7
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
37 addition
and
9 deletion
+37
-9
cmd/geth/main.go
cmd/geth/main.go
+1
-0
cmd/utils/flags.go
cmd/utils/flags.go
+5
-1
eth/backend.go
eth/backend.go
+2
-0
p2p/server.go
p2p/server.go
+29
-8
未找到文件。
cmd/geth/main.go
浏览文件 @
e1a0ee8f
...
...
@@ -260,6 +260,7 @@ JavaScript API. See https://github.com/ethereum/go-ethereum/wiki/Javascipt-Conso
utils
.
AutoDAGFlag
,
utils
.
NATFlag
,
utils
.
NatspecEnabledFlag
,
utils
.
NoDiscoverFlag
,
utils
.
NodeKeyFileFlag
,
utils
.
NodeKeyHexFlag
,
utils
.
RPCEnabledFlag
,
...
...
cmd/utils/flags.go
浏览文件 @
e1a0ee8f
...
...
@@ -235,6 +235,10 @@ var (
Usage
:
"NAT port mapping mechanism (any|none|upnp|pmp|extip:<IP>)"
,
Value
:
"any"
,
}
NoDiscoverFlag
=
cli
.
BoolFlag
{
Name
:
"nodiscover"
,
Usage
:
"Disables the peer discovery mechanism (manual peer addition)"
,
}
WhisperEnabledFlag
=
cli
.
BoolFlag
{
Name
:
"shh"
,
Usage
:
"Enable whisper"
,
...
...
@@ -312,6 +316,7 @@ func MakeEthConfig(clientID, version string, ctx *cli.Context) *eth.Config {
Port
:
ctx
.
GlobalString
(
ListenPortFlag
.
Name
),
NAT
:
GetNAT
(
ctx
),
NatSpec
:
ctx
.
GlobalBool
(
NatspecEnabledFlag
.
Name
),
Discovery
:
!
ctx
.
GlobalBool
(
NoDiscoverFlag
.
Name
),
NodeKey
:
GetNodeKey
(
ctx
),
Shh
:
ctx
.
GlobalBool
(
WhisperEnabledFlag
.
Name
),
Dial
:
true
,
...
...
@@ -320,7 +325,6 @@ func MakeEthConfig(clientID, version string, ctx *cli.Context) *eth.Config {
SolcPath
:
ctx
.
GlobalString
(
SolcPathFlag
.
Name
),
AutoDAG
:
ctx
.
GlobalBool
(
AutoDAGFlag
.
Name
)
||
ctx
.
GlobalBool
(
MiningEnabledFlag
.
Name
),
}
}
func
GetChain
(
ctx
*
cli
.
Context
)
(
*
core
.
ChainManager
,
common
.
Database
,
common
.
Database
)
{
...
...
eth/backend.go
浏览文件 @
e1a0ee8f
...
...
@@ -72,6 +72,7 @@ type Config struct {
MaxPeers
int
MaxPendingPeers
int
Discovery
bool
Port
string
// Space-separated list of discovery node URLs
...
...
@@ -311,6 +312,7 @@ func New(config *Config) (*Ethereum, error) {
Name
:
config
.
Name
,
MaxPeers
:
config
.
MaxPeers
,
MaxPendingPeers
:
config
.
MaxPendingPeers
,
Discovery
:
config
.
Discovery
,
Protocols
:
protocols
,
NAT
:
config
.
NAT
,
NoDial
:
!
config
.
Dial
,
...
...
p2p/server.go
浏览文件 @
e1a0ee8f
...
...
@@ -55,6 +55,10 @@ type Server struct {
// Zero defaults to preset values.
MaxPendingPeers
int
// Discovery specifies whether the peer discovery mechanism should be started
// or not. Disabling is usually useful for protocol debugging (manual topology).
Discovery
bool
// Name sets the node name of this server.
// Use common.MakeName to create a name that follows existing conventions.
Name
string
...
...
@@ -240,6 +244,14 @@ func (srv *Server) Self() *discover.Node {
if
!
srv
.
running
{
return
&
discover
.
Node
{
IP
:
net
.
ParseIP
(
"0.0.0.0"
)}
}
if
srv
.
ntab
==
nil
{
addr
:=
srv
.
listener
.
Addr
()
.
(
*
net
.
TCPAddr
)
return
&
discover
.
Node
{
ID
:
discover
.
PubkeyID
(
&
srv
.
PrivateKey
.
PublicKey
),
IP
:
addr
.
IP
,
TCP
:
uint16
(
addr
.
Port
),
}
}
return
srv
.
ntab
.
Self
()
}
...
...
@@ -290,15 +302,22 @@ func (srv *Server) Start() (err error) {
srv
.
peerOpDone
=
make
(
chan
struct
{})
// node table
ntab
,
err
:=
discover
.
ListenUDP
(
srv
.
PrivateKey
,
srv
.
ListenAddr
,
srv
.
NAT
,
srv
.
NodeDatabase
)
if
err
!=
nil
{
return
err
if
srv
.
Discovery
{
ntab
,
err
:=
discover
.
ListenUDP
(
srv
.
PrivateKey
,
srv
.
ListenAddr
,
srv
.
NAT
,
srv
.
NodeDatabase
)
if
err
!=
nil
{
return
err
}
srv
.
ntab
=
ntab
}
srv
.
ntab
=
ntab
dialer
:=
newDialState
(
srv
.
StaticNodes
,
srv
.
ntab
,
srv
.
MaxPeers
/
2
)
dynPeers
:=
srv
.
MaxPeers
/
2
if
!
srv
.
Discovery
{
dynPeers
=
0
}
dialer
:=
newDialState
(
srv
.
StaticNodes
,
srv
.
ntab
,
dynPeers
)
// handshake
srv
.
ourHandshake
=
&
protoHandshake
{
Version
:
baseProtocolVersion
,
Name
:
srv
.
Name
,
ID
:
ntab
.
Self
()
.
ID
}
srv
.
ourHandshake
=
&
protoHandshake
{
Version
:
baseProtocolVersion
,
Name
:
srv
.
Name
,
ID
:
discover
.
PubkeyID
(
&
srv
.
PrivateKey
.
PublicKey
)
}
for
_
,
p
:=
range
srv
.
Protocols
{
srv
.
ourHandshake
.
Caps
=
append
(
srv
.
ourHandshake
.
Caps
,
p
.
cap
())
}
...
...
@@ -454,7 +473,9 @@ running:
}
// Terminate discovery. If there is a running lookup it will terminate soon.
srv
.
ntab
.
Close
()
if
srv
.
ntab
!=
nil
{
srv
.
ntab
.
Close
()
}
// Disconnect all peers.
for
_
,
p
:=
range
peers
{
p
.
Disconnect
(
DiscQuitting
)
...
...
@@ -486,7 +507,7 @@ func (srv *Server) encHandshakeChecks(peers map[discover.NodeID]*Peer, c *conn)
return
DiscTooManyPeers
case
peers
[
c
.
id
]
!=
nil
:
return
DiscAlreadyConnected
case
c
.
id
==
srv
.
ntab
.
Self
()
.
ID
:
case
c
.
id
==
srv
.
Self
()
.
ID
:
return
DiscSelf
default
:
return
nil
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录