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
e1a0ee8f
Commit
e1a0ee8f
authored
May 26, 2015
by
Péter Szilágyi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cmd/geth, cmd/utils, eth, p2p: pass and honor a no discovery flag
parent
278183c7
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
37 additions
and
9 deletions
+37
-9
main.go
cmd/geth/main.go
+1
-0
flags.go
cmd/utils/flags.go
+5
-1
backend.go
eth/backend.go
+2
-0
server.go
p2p/server.go
+29
-8
No files found.
cmd/geth/main.go
View file @
e1a0ee8f
...
@@ -260,6 +260,7 @@ JavaScript API. See https://github.com/ethereum/go-ethereum/wiki/Javascipt-Conso
...
@@ -260,6 +260,7 @@ JavaScript API. See https://github.com/ethereum/go-ethereum/wiki/Javascipt-Conso
utils
.
AutoDAGFlag
,
utils
.
AutoDAGFlag
,
utils
.
NATFlag
,
utils
.
NATFlag
,
utils
.
NatspecEnabledFlag
,
utils
.
NatspecEnabledFlag
,
utils
.
NoDiscoverFlag
,
utils
.
NodeKeyFileFlag
,
utils
.
NodeKeyFileFlag
,
utils
.
NodeKeyHexFlag
,
utils
.
NodeKeyHexFlag
,
utils
.
RPCEnabledFlag
,
utils
.
RPCEnabledFlag
,
...
...
cmd/utils/flags.go
View file @
e1a0ee8f
...
@@ -235,6 +235,10 @@ var (
...
@@ -235,6 +235,10 @@ var (
Usage
:
"NAT port mapping mechanism (any|none|upnp|pmp|extip:<IP>)"
,
Usage
:
"NAT port mapping mechanism (any|none|upnp|pmp|extip:<IP>)"
,
Value
:
"any"
,
Value
:
"any"
,
}
}
NoDiscoverFlag
=
cli
.
BoolFlag
{
Name
:
"nodiscover"
,
Usage
:
"Disables the peer discovery mechanism (manual peer addition)"
,
}
WhisperEnabledFlag
=
cli
.
BoolFlag
{
WhisperEnabledFlag
=
cli
.
BoolFlag
{
Name
:
"shh"
,
Name
:
"shh"
,
Usage
:
"Enable whisper"
,
Usage
:
"Enable whisper"
,
...
@@ -312,6 +316,7 @@ func MakeEthConfig(clientID, version string, ctx *cli.Context) *eth.Config {
...
@@ -312,6 +316,7 @@ func MakeEthConfig(clientID, version string, ctx *cli.Context) *eth.Config {
Port
:
ctx
.
GlobalString
(
ListenPortFlag
.
Name
),
Port
:
ctx
.
GlobalString
(
ListenPortFlag
.
Name
),
NAT
:
GetNAT
(
ctx
),
NAT
:
GetNAT
(
ctx
),
NatSpec
:
ctx
.
GlobalBool
(
NatspecEnabledFlag
.
Name
),
NatSpec
:
ctx
.
GlobalBool
(
NatspecEnabledFlag
.
Name
),
Discovery
:
!
ctx
.
GlobalBool
(
NoDiscoverFlag
.
Name
),
NodeKey
:
GetNodeKey
(
ctx
),
NodeKey
:
GetNodeKey
(
ctx
),
Shh
:
ctx
.
GlobalBool
(
WhisperEnabledFlag
.
Name
),
Shh
:
ctx
.
GlobalBool
(
WhisperEnabledFlag
.
Name
),
Dial
:
true
,
Dial
:
true
,
...
@@ -320,7 +325,6 @@ func MakeEthConfig(clientID, version string, ctx *cli.Context) *eth.Config {
...
@@ -320,7 +325,6 @@ func MakeEthConfig(clientID, version string, ctx *cli.Context) *eth.Config {
SolcPath
:
ctx
.
GlobalString
(
SolcPathFlag
.
Name
),
SolcPath
:
ctx
.
GlobalString
(
SolcPathFlag
.
Name
),
AutoDAG
:
ctx
.
GlobalBool
(
AutoDAGFlag
.
Name
)
||
ctx
.
GlobalBool
(
MiningEnabledFlag
.
Name
),
AutoDAG
:
ctx
.
GlobalBool
(
AutoDAGFlag
.
Name
)
||
ctx
.
GlobalBool
(
MiningEnabledFlag
.
Name
),
}
}
}
}
func
GetChain
(
ctx
*
cli
.
Context
)
(
*
core
.
ChainManager
,
common
.
Database
,
common
.
Database
)
{
func
GetChain
(
ctx
*
cli
.
Context
)
(
*
core
.
ChainManager
,
common
.
Database
,
common
.
Database
)
{
...
...
eth/backend.go
View file @
e1a0ee8f
...
@@ -72,6 +72,7 @@ type Config struct {
...
@@ -72,6 +72,7 @@ type Config struct {
MaxPeers
int
MaxPeers
int
MaxPendingPeers
int
MaxPendingPeers
int
Discovery
bool
Port
string
Port
string
// Space-separated list of discovery node URLs
// Space-separated list of discovery node URLs
...
@@ -311,6 +312,7 @@ func New(config *Config) (*Ethereum, error) {
...
@@ -311,6 +312,7 @@ func New(config *Config) (*Ethereum, error) {
Name
:
config
.
Name
,
Name
:
config
.
Name
,
MaxPeers
:
config
.
MaxPeers
,
MaxPeers
:
config
.
MaxPeers
,
MaxPendingPeers
:
config
.
MaxPendingPeers
,
MaxPendingPeers
:
config
.
MaxPendingPeers
,
Discovery
:
config
.
Discovery
,
Protocols
:
protocols
,
Protocols
:
protocols
,
NAT
:
config
.
NAT
,
NAT
:
config
.
NAT
,
NoDial
:
!
config
.
Dial
,
NoDial
:
!
config
.
Dial
,
...
...
p2p/server.go
View file @
e1a0ee8f
...
@@ -55,6 +55,10 @@ type Server struct {
...
@@ -55,6 +55,10 @@ type Server struct {
// Zero defaults to preset values.
// Zero defaults to preset values.
MaxPendingPeers
int
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.
// Name sets the node name of this server.
// Use common.MakeName to create a name that follows existing conventions.
// Use common.MakeName to create a name that follows existing conventions.
Name
string
Name
string
...
@@ -240,6 +244,14 @@ func (srv *Server) Self() *discover.Node {
...
@@ -240,6 +244,14 @@ func (srv *Server) Self() *discover.Node {
if
!
srv
.
running
{
if
!
srv
.
running
{
return
&
discover
.
Node
{
IP
:
net
.
ParseIP
(
"0.0.0.0"
)}
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
()
return
srv
.
ntab
.
Self
()
}
}
...
@@ -290,15 +302,22 @@ func (srv *Server) Start() (err error) {
...
@@ -290,15 +302,22 @@ func (srv *Server) Start() (err error) {
srv
.
peerOpDone
=
make
(
chan
struct
{})
srv
.
peerOpDone
=
make
(
chan
struct
{})
// node table
// node table
ntab
,
err
:=
discover
.
ListenUDP
(
srv
.
PrivateKey
,
srv
.
ListenAddr
,
srv
.
NAT
,
srv
.
NodeDatabase
)
if
srv
.
Discovery
{
if
err
!=
nil
{
ntab
,
err
:=
discover
.
ListenUDP
(
srv
.
PrivateKey
,
srv
.
ListenAddr
,
srv
.
NAT
,
srv
.
NodeDatabase
)
return
err
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
// 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
{
for
_
,
p
:=
range
srv
.
Protocols
{
srv
.
ourHandshake
.
Caps
=
append
(
srv
.
ourHandshake
.
Caps
,
p
.
cap
())
srv
.
ourHandshake
.
Caps
=
append
(
srv
.
ourHandshake
.
Caps
,
p
.
cap
())
}
}
...
@@ -454,7 +473,9 @@ running:
...
@@ -454,7 +473,9 @@ running:
}
}
// Terminate discovery. If there is a running lookup it will terminate soon.
// 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.
// Disconnect all peers.
for
_
,
p
:=
range
peers
{
for
_
,
p
:=
range
peers
{
p
.
Disconnect
(
DiscQuitting
)
p
.
Disconnect
(
DiscQuitting
)
...
@@ -486,7 +507,7 @@ func (srv *Server) encHandshakeChecks(peers map[discover.NodeID]*Peer, c *conn)
...
@@ -486,7 +507,7 @@ func (srv *Server) encHandshakeChecks(peers map[discover.NodeID]*Peer, c *conn)
return
DiscTooManyPeers
return
DiscTooManyPeers
case
peers
[
c
.
id
]
!=
nil
:
case
peers
[
c
.
id
]
!=
nil
:
return
DiscAlreadyConnected
return
DiscAlreadyConnected
case
c
.
id
==
srv
.
ntab
.
Self
()
.
ID
:
case
c
.
id
==
srv
.
Self
()
.
ID
:
return
DiscSelf
return
DiscSelf
default
:
default
:
return
nil
return
nil
...
...
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