diff options
author | obscuren <geffobscura@gmail.com> | 2014-05-09 22:09:28 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2014-05-09 22:09:28 +0800 |
commit | afe83af219c2146e022f6665cf30097b582d3e79 (patch) | |
tree | 74ce21d3ea64b1a433ffb723c0171a4071e42392 /ethereum.go | |
parent | 5a0bae1dae831818740a2f20ca308c4176f5201d (diff) | |
download | dexon-afe83af219c2146e022f6665cf30097b582d3e79.tar dexon-afe83af219c2146e022f6665cf30097b582d3e79.tar.gz dexon-afe83af219c2146e022f6665cf30097b582d3e79.tar.bz2 dexon-afe83af219c2146e022f6665cf30097b582d3e79.tar.lz dexon-afe83af219c2146e022f6665cf30097b582d3e79.tar.xz dexon-afe83af219c2146e022f6665cf30097b582d3e79.tar.zst dexon-afe83af219c2146e022f6665cf30097b582d3e79.zip |
Moved seeding and moved manifest
Diffstat (limited to 'ethereum.go')
-rw-r--r-- | ethereum.go | 82 |
1 files changed, 43 insertions, 39 deletions
diff --git a/ethereum.go b/ethereum.go index 2f4db7336..e3140b5ce 100644 --- a/ethereum.go +++ b/ethereum.go @@ -253,7 +253,7 @@ func (s *Ethereum) ReapDeadPeerHandler() { } // Start the ethereum -func (s *Ethereum) Start() { +func (s *Ethereum) Start(seed bool) { // Bind to addr and port ln, err := net.Listen("tcp", ":"+s.Port) if err != nil { @@ -272,47 +272,51 @@ func (s *Ethereum) Start() { // Start the reaping processes go s.ReapDeadPeerHandler() - if ethutil.Config.Seed { - ethutil.Config.Log.Debugln("Seeding") - // DNS Bootstrapping - _, nodes, err := net.LookupSRV("eth", "tcp", "ethereum.org") - if err == nil { - peers := []string{} - // Iterate SRV nodes - for _, n := range nodes { - target := n.Target - port := strconv.Itoa(int(n.Port)) - // Resolve target to ip (Go returns list, so may resolve to multiple ips?) - addr, err := net.LookupHost(target) - 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) + if seed { + s.Seed() + } +} + +func (s *Ethereum) Seed() { + ethutil.Config.Log.Debugln("Seeding") + // DNS Bootstrapping + _, nodes, err := net.LookupSRV("eth", "tcp", "ethereum.org") + if err == nil { + peers := []string{} + // Iterate SRV nodes + for _, n := range nodes { + target := n.Target + port := strconv.Itoa(int(n.Port)) + // Resolve target to ip (Go returns list, so may resolve to multiple ips?) + addr, err := net.LookupHost(target) + 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)) } + // 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)) } } |