mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-22 20:56:42 +00:00
add peers cli flag
This commit is contained in:
parent
bef46b0d6b
commit
f9efeb6594
4 changed files with 13 additions and 5 deletions
|
|
@ -65,6 +65,7 @@ var (
|
|||
SHH bool
|
||||
Dial bool
|
||||
PrintVersion bool
|
||||
Peers string
|
||||
)
|
||||
|
||||
// flags specific to cli client
|
||||
|
|
@ -103,6 +104,7 @@ func Init() {
|
|||
flag.BoolVar(&SHH, "shh", true, "whisper protocol (on)")
|
||||
flag.BoolVar(&Dial, "dial", true, "dial out connections (on)")
|
||||
flag.BoolVar(&GenAddr, "genaddr", false, "create a new priv/pub key")
|
||||
flag.StringVar(&Peers, "peers", "", "imports the file given (hex or mnemonic formats)")
|
||||
flag.StringVar(&SecretFile, "import", "", "imports the file given (hex or mnemonic formats)")
|
||||
flag.StringVar(&ExportDir, "export", "", "exports the session keyring to files in the directory given")
|
||||
flag.StringVar(&LogFile, "logfile", "", "log file (defaults to standard output)")
|
||||
|
|
|
|||
|
|
@ -134,7 +134,7 @@ func main() {
|
|||
utils.StartWebSockets(ethereum)
|
||||
}
|
||||
|
||||
utils.StartEthereum(ethereum, UseSeed)
|
||||
utils.StartEthereum(ethereum, UseSeed, Peers)
|
||||
|
||||
if StartJsConsole {
|
||||
InitJsConsole(ethereum)
|
||||
|
|
|
|||
|
|
@ -120,9 +120,9 @@ func exit(err error) {
|
|||
os.Exit(status)
|
||||
}
|
||||
|
||||
func StartEthereum(ethereum *eth.Ethereum, UseSeed bool) {
|
||||
func StartEthereum(ethereum *eth.Ethereum, UseSeed bool, Peers string) {
|
||||
clilogger.Infof("Starting %s", ethereum.ClientIdentity())
|
||||
err := ethereum.Start(UseSeed)
|
||||
err := ethereum.Start(UseSeed, Peers)
|
||||
if err != nil {
|
||||
exit(err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ import (
|
|||
)
|
||||
|
||||
const (
|
||||
seedNodeAddress = "10.0.2.41:30303"
|
||||
seedNodeAddress = "10.0.1.41:30303"
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
|
|
@ -233,7 +233,7 @@ func (s *Ethereum) MaxPeers() int {
|
|||
}
|
||||
|
||||
// Start the ethereum
|
||||
func (s *Ethereum) Start(seed bool) error {
|
||||
func (s *Ethereum) Start(seed bool, p string) error {
|
||||
err := s.net.Start()
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
@ -255,6 +255,12 @@ func (s *Ethereum) Start(seed bool) error {
|
|||
s.blockSub = s.eventMux.Subscribe(core.NewMinedBlockEvent{})
|
||||
go s.blockBroadcastLoop()
|
||||
|
||||
if len(p) > 0 {
|
||||
if err := s.SuggestPeer(p); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: read peers here
|
||||
if seed {
|
||||
logger.Infof("Connect to seed node %v", seedNodeAddress)
|
||||
|
|
|
|||
Loading…
Reference in a new issue