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
028775a0
Commit
028775a0
authored
Feb 06, 2015
by
Felix Lange
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cmd/ethereum, cmd/mist: add flag for discovery bootstrap nodes
parent
2cf4fed1
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
43 additions
and
22 deletions
+43
-22
flags.go
cmd/ethereum/flags.go
+2
-2
main.go
cmd/ethereum/main.go
+2
-1
flags.go
cmd/mist/flags.go
+2
-2
main.go
cmd/mist/main.go
+3
-2
ui_lib.go
cmd/mist/ui_lib.go
+1
-1
cmd.go
cmd/utils/cmd.go
+2
-2
backend.go
eth/backend.go
+28
-9
table.go
p2p/discover/table.go
+2
-2
server.go
p2p/server.go
+1
-1
No files found.
cmd/ethereum/flags.go
View file @
028775a0
...
@@ -49,7 +49,7 @@ var (
...
@@ -49,7 +49,7 @@ var (
AddPeer
string
AddPeer
string
MaxPeer
int
MaxPeer
int
GenAddr
bool
GenAddr
bool
SeedNode
string
BootNodes
string
SecretFile
string
SecretFile
string
ExportDir
string
ExportDir
string
NonInteractive
bool
NonInteractive
bool
...
@@ -101,7 +101,7 @@ func Init() {
...
@@ -101,7 +101,7 @@ func Init() {
flag
.
BoolVar
(
&
StartRpc
,
"rpc"
,
false
,
"start rpc server"
)
flag
.
BoolVar
(
&
StartRpc
,
"rpc"
,
false
,
"start rpc server"
)
flag
.
BoolVar
(
&
StartWebSockets
,
"ws"
,
false
,
"start websocket server"
)
flag
.
BoolVar
(
&
StartWebSockets
,
"ws"
,
false
,
"start websocket server"
)
flag
.
BoolVar
(
&
NonInteractive
,
"y"
,
false
,
"non-interactive mode (say yes to confirmations)"
)
flag
.
BoolVar
(
&
NonInteractive
,
"y"
,
false
,
"non-interactive mode (say yes to confirmations)"
)
flag
.
StringVar
(
&
SeedNode
,
"seednode"
,
"poc-8.ethdev.com:30303"
,
"ip:port of seed node to connect to. Set to blank for ski
p"
)
flag
.
StringVar
(
&
BootNodes
,
"bootnodes"
,
""
,
"space-separated node URLs for discovery bootstra
p"
)
flag
.
BoolVar
(
&
SHH
,
"shh"
,
true
,
"whisper protocol (on)"
)
flag
.
BoolVar
(
&
SHH
,
"shh"
,
true
,
"whisper protocol (on)"
)
flag
.
BoolVar
(
&
Dial
,
"dial"
,
true
,
"dial out connections (on)"
)
flag
.
BoolVar
(
&
Dial
,
"dial"
,
true
,
"dial out connections (on)"
)
flag
.
BoolVar
(
&
GenAddr
,
"genaddr"
,
false
,
"create a new priv/pub key"
)
flag
.
BoolVar
(
&
GenAddr
,
"genaddr"
,
false
,
"create a new priv/pub key"
)
...
...
cmd/ethereum/main.go
View file @
028775a0
...
@@ -74,6 +74,7 @@ func main() {
...
@@ -74,6 +74,7 @@ func main() {
KeyRing
:
KeyRing
,
KeyRing
:
KeyRing
,
Shh
:
SHH
,
Shh
:
SHH
,
Dial
:
Dial
,
Dial
:
Dial
,
BootNodes
:
BootNodes
,
})
})
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -133,7 +134,7 @@ func main() {
...
@@ -133,7 +134,7 @@ func main() {
utils
.
StartWebSockets
(
ethereum
,
WsPort
)
utils
.
StartWebSockets
(
ethereum
,
WsPort
)
}
}
utils
.
StartEthereum
(
ethereum
,
SeedNode
)
utils
.
StartEthereum
(
ethereum
)
if
StartJsConsole
{
if
StartJsConsole
{
InitJsConsole
(
ethereum
)
InitJsConsole
(
ethereum
)
...
...
cmd/mist/flags.go
View file @
028775a0
...
@@ -51,7 +51,7 @@ var (
...
@@ -51,7 +51,7 @@ var (
AddPeer
string
AddPeer
string
MaxPeer
int
MaxPeer
int
GenAddr
bool
GenAddr
bool
SeedNode
string
BootNodes
string
SecretFile
string
SecretFile
string
ExportDir
string
ExportDir
string
NonInteractive
bool
NonInteractive
bool
...
@@ -116,7 +116,7 @@ func Init() {
...
@@ -116,7 +116,7 @@ func Init() {
flag
.
BoolVar
(
&
StartRpc
,
"rpc"
,
true
,
"start rpc server"
)
flag
.
BoolVar
(
&
StartRpc
,
"rpc"
,
true
,
"start rpc server"
)
flag
.
BoolVar
(
&
StartWebSockets
,
"ws"
,
false
,
"start websocket server"
)
flag
.
BoolVar
(
&
StartWebSockets
,
"ws"
,
false
,
"start websocket server"
)
flag
.
BoolVar
(
&
NonInteractive
,
"y"
,
false
,
"non-interactive mode (say yes to confirmations)"
)
flag
.
BoolVar
(
&
NonInteractive
,
"y"
,
false
,
"non-interactive mode (say yes to confirmations)"
)
flag
.
StringVar
(
&
SeedNode
,
"seednode"
,
"poc-8.ethdev.com:30303"
,
"ip:port of seed node to connect to. Set to blank for ski
p"
)
flag
.
StringVar
(
&
BootNodes
,
"bootnodes"
,
""
,
"space-separated node URLs for discovery bootstra
p"
)
flag
.
BoolVar
(
&
GenAddr
,
"genaddr"
,
false
,
"create a new priv/pub key"
)
flag
.
BoolVar
(
&
GenAddr
,
"genaddr"
,
false
,
"create a new priv/pub key"
)
flag
.
StringVar
(
&
NatType
,
"nat"
,
""
,
"NAT support (UPNP|PMP) (none)"
)
flag
.
StringVar
(
&
NatType
,
"nat"
,
""
,
"NAT support (UPNP|PMP) (none)"
)
flag
.
StringVar
(
&
SecretFile
,
"import"
,
""
,
"imports the file given (hex or mnemonic formats)"
)
flag
.
StringVar
(
&
SecretFile
,
"import"
,
""
,
"imports the file given (hex or mnemonic formats)"
)
...
...
cmd/mist/main.go
View file @
028775a0
...
@@ -59,8 +59,9 @@ func run() error {
...
@@ -59,8 +59,9 @@ func run() error {
LogLevel
:
LogLevel
,
LogLevel
:
LogLevel
,
MaxPeers
:
MaxPeer
,
MaxPeers
:
MaxPeer
,
Port
:
OutboundPort
,
Port
:
OutboundPort
,
NATType
:
PMPGateway
,
NATType
:
NatType
,
PMPGateway
:
PMPGateway
,
PMPGateway
:
PMPGateway
,
BootNodes
:
BootNodes
,
KeyRing
:
KeyRing
,
KeyRing
:
KeyRing
,
Dial
:
true
,
Dial
:
true
,
})
})
...
@@ -82,7 +83,7 @@ func run() error {
...
@@ -82,7 +83,7 @@ func run() error {
utils
.
RegisterInterrupt
(
func
(
os
.
Signal
)
{
utils
.
RegisterInterrupt
(
func
(
os
.
Signal
)
{
gui
.
Stop
()
gui
.
Stop
()
})
})
go
utils
.
StartEthereum
(
ethereum
,
SeedNode
)
go
utils
.
StartEthereum
(
ethereum
)
fmt
.
Println
(
"ETH stack took"
,
time
.
Since
(
tstart
))
fmt
.
Println
(
"ETH stack took"
,
time
.
Since
(
tstart
))
...
...
cmd/mist/ui_lib.go
View file @
028775a0
...
@@ -136,7 +136,7 @@ func (ui *UiLib) Muted(content string) {
...
@@ -136,7 +136,7 @@ func (ui *UiLib) Muted(content string) {
func
(
ui
*
UiLib
)
Connect
(
button
qml
.
Object
)
{
func
(
ui
*
UiLib
)
Connect
(
button
qml
.
Object
)
{
if
!
ui
.
connected
{
if
!
ui
.
connected
{
ui
.
eth
.
Start
(
SeedNode
)
ui
.
eth
.
Start
()
ui
.
connected
=
true
ui
.
connected
=
true
button
.
Set
(
"enabled"
,
false
)
button
.
Set
(
"enabled"
,
false
)
}
}
...
...
cmd/utils/cmd.go
View file @
028775a0
...
@@ -121,9 +121,9 @@ func exit(err error) {
...
@@ -121,9 +121,9 @@ func exit(err error) {
os
.
Exit
(
status
)
os
.
Exit
(
status
)
}
}
func
StartEthereum
(
ethereum
*
eth
.
Ethereum
,
SeedNode
string
)
{
func
StartEthereum
(
ethereum
*
eth
.
Ethereum
)
{
clilogger
.
Infoln
(
"Starting "
,
ethereum
.
Name
())
clilogger
.
Infoln
(
"Starting "
,
ethereum
.
Name
())
if
err
:=
ethereum
.
Start
(
SeedNode
);
err
!=
nil
{
if
err
:=
ethereum
.
Start
();
err
!=
nil
{
exit
(
err
)
exit
(
err
)
}
}
RegisterInterrupt
(
func
(
sig
os
.
Signal
)
{
RegisterInterrupt
(
func
(
sig
os
.
Signal
)
{
...
...
eth/backend.go
View file @
028775a0
...
@@ -2,6 +2,7 @@ package eth
...
@@ -2,6 +2,7 @@ package eth
import
(
import
(
"fmt"
"fmt"
"strings"
"sync"
"sync"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core"
...
@@ -17,6 +18,8 @@ import (
...
@@ -17,6 +18,8 @@ import (
"github.com/ethereum/go-ethereum/whisper"
"github.com/ethereum/go-ethereum/whisper"
)
)
var
logger
=
ethlogger
.
NewLogger
(
"SERV"
)
type
Config
struct
{
type
Config
struct
{
Name
string
Name
string
KeyStore
string
KeyStore
string
...
@@ -30,13 +33,28 @@ type Config struct {
...
@@ -30,13 +33,28 @@ type Config struct {
NATType
string
NATType
string
PMPGateway
string
PMPGateway
string
// This should be a space-separated list of
// discovery node URLs.
BootNodes
string
Shh
bool
Shh
bool
Dial
bool
Dial
bool
KeyManager
*
crypto
.
KeyManager
KeyManager
*
crypto
.
KeyManager
}
}
var
logger
=
ethlogger
.
NewLogger
(
"SERV"
)
func
(
cfg
*
Config
)
parseBootNodes
()
[]
*
discover
.
Node
{
var
ns
[]
*
discover
.
Node
for
_
,
url
:=
range
strings
.
Split
(
cfg
.
BootNodes
,
" "
)
{
n
,
err
:=
discover
.
ParseNode
(
url
)
if
err
!=
nil
{
logger
.
Errorf
(
"Bootstrap URL %s: %v
\n
"
,
url
,
err
)
continue
}
ns
=
append
(
ns
,
n
)
}
return
ns
}
type
Ethereum
struct
{
type
Ethereum
struct
{
// Channel for shutting down the ethereum
// Channel for shutting down the ethereum
...
@@ -134,13 +152,14 @@ func New(config *Config) (*Ethereum, error) {
...
@@ -134,13 +152,14 @@ func New(config *Config) (*Ethereum, error) {
return
nil
,
fmt
.
Errorf
(
"could not generate server key: %v"
,
err
)
return
nil
,
fmt
.
Errorf
(
"could not generate server key: %v"
,
err
)
}
}
eth
.
net
=
&
p2p
.
Server
{
eth
.
net
=
&
p2p
.
Server
{
PrivateKey
:
netprv
,
PrivateKey
:
netprv
,
Name
:
config
.
Name
,
Name
:
config
.
Name
,
MaxPeers
:
config
.
MaxPeers
,
MaxPeers
:
config
.
MaxPeers
,
Protocols
:
protocols
,
Protocols
:
protocols
,
Blacklist
:
eth
.
blacklist
,
Blacklist
:
eth
.
blacklist
,
NAT
:
nat
,
NAT
:
nat
,
NoDial
:
!
config
.
Dial
,
NoDial
:
!
config
.
Dial
,
BootstrapNodes
:
config
.
parseBootNodes
(),
}
}
if
len
(
config
.
Port
)
>
0
{
if
len
(
config
.
Port
)
>
0
{
eth
.
net
.
ListenAddr
=
":"
+
config
.
Port
eth
.
net
.
ListenAddr
=
":"
+
config
.
Port
...
@@ -214,7 +233,7 @@ func (s *Ethereum) Coinbase() []byte {
...
@@ -214,7 +233,7 @@ func (s *Ethereum) Coinbase() []byte {
}
}
// Start the ethereum
// Start the ethereum
func
(
s
*
Ethereum
)
Start
(
seedNode
string
)
error
{
func
(
s
*
Ethereum
)
Start
()
error
{
err
:=
s
.
net
.
Start
()
err
:=
s
.
net
.
Start
()
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
...
...
p2p/discover/table.go
View file @
028775a0
...
@@ -65,12 +65,12 @@ func (tab *Table) Close() {
...
@@ -65,12 +65,12 @@ func (tab *Table) Close() {
// to the network if the table is empty. Bootstrap will also attempt to
// to the network if the table is empty. Bootstrap will also attempt to
// fill the table by performing random lookup operations on the
// fill the table by performing random lookup operations on the
// network.
// network.
func
(
tab
*
Table
)
Bootstrap
(
nodes
[]
Node
)
{
func
(
tab
*
Table
)
Bootstrap
(
nodes
[]
*
Node
)
{
tab
.
mutex
.
Lock
()
tab
.
mutex
.
Lock
()
// TODO: maybe filter nodes with bad fields (nil, etc.) to avoid strange crashes
// TODO: maybe filter nodes with bad fields (nil, etc.) to avoid strange crashes
tab
.
nursery
=
make
([]
*
Node
,
0
,
len
(
nodes
))
tab
.
nursery
=
make
([]
*
Node
,
0
,
len
(
nodes
))
for
_
,
n
:=
range
nodes
{
for
_
,
n
:=
range
nodes
{
cpy
:=
n
cpy
:=
*
n
tab
.
nursery
=
append
(
tab
.
nursery
,
&
cpy
)
tab
.
nursery
=
append
(
tab
.
nursery
,
&
cpy
)
}
}
tab
.
mutex
.
Unlock
()
tab
.
mutex
.
Unlock
()
...
...
p2p/server.go
View file @
028775a0
...
@@ -50,7 +50,7 @@ type Server struct {
...
@@ -50,7 +50,7 @@ type Server struct {
// Bootstrap nodes are used to establish connectivity
// Bootstrap nodes are used to establish connectivity
// with the rest of the network.
// with the rest of the network.
BootstrapNodes
[]
discover
.
Node
BootstrapNodes
[]
*
discover
.
Node
// Protocols should contain the protocols supported
// Protocols should contain the protocols supported
// by the server. Matching protocols are launched for
// by the server. Matching protocols are launched for
...
...
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