mirror of https://github.com/status-im/op-geth.git
Merge branch 'develop' of https://github.com/jarradh/eth-go into jarradh-develop
This commit is contained in:
commit
54bcee512d
51
ethereum.go
51
ethereum.go
|
@ -263,20 +263,45 @@ func (s *Ethereum) Start() {
|
||||||
|
|
||||||
if ethutil.Config.Seed {
|
if ethutil.Config.Seed {
|
||||||
ethutil.Config.Log.Debugln("Seeding")
|
ethutil.Config.Log.Debugln("Seeding")
|
||||||
// Testnet seed bootstrapping
|
// DNS Bootstrapping
|
||||||
resp, err := http.Get("https://www.ethereum.org/servers.poc3.txt")
|
_, nodes, err := net.LookupSRV("eth", "tcp", "ethereum.org")
|
||||||
if err != nil {
|
if err == nil {
|
||||||
log.Println("Fetching seed failed:", err)
|
peers := []string{}
|
||||||
return
|
// Iterate SRV nodes
|
||||||
}
|
for _, n := range nodes {
|
||||||
defer resp.Body.Close()
|
target := n.Target
|
||||||
body, err := ioutil.ReadAll(resp.Body)
|
port := strconv.Itoa(int(n.Port))
|
||||||
if err != nil {
|
// Resolve target to ip (Go returns list, so may resolve to multiple ips?)
|
||||||
log.Println("Reading seed failed:", err)
|
addr, err := net.LookupHost(target)
|
||||||
return
|
if err == nil {
|
||||||
}
|
for _, a := range addr {
|
||||||
|
// Build string out of SRV port and Resolved IP
|
||||||
|
peer := net.JoinHostPort(a, port)
|
||||||
|
log.Println("Found DNS Bootstrap Peer:", peer)
|
||||||
|
peers = append(peers, peer)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
log.Println("Couldn't resolve :", target)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Connect to Peer list
|
||||||
|
s.ProcessPeerList(peers)
|
||||||
|
} else {
|
||||||
|
// Fallback to servers.poc3.txt
|
||||||
|
resp, err := http.Get("http://www.ethereum.org/servers.poc3.txt")
|
||||||
|
if err != nil {
|
||||||
|
log.Println("Fetching seed failed:", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
defer resp.Body.Close()
|
||||||
|
body, err := ioutil.ReadAll(resp.Body)
|
||||||
|
if err != nil {
|
||||||
|
log.Println("Reading seed failed:", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
s.ConnectToPeer(string(body))
|
s.ConnectToPeer(string(body))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue