aboutsummaryrefslogtreecommitdiffstats
path: root/ethereum.go
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-05-09 22:09:28 +0800
committerobscuren <geffobscura@gmail.com>2014-05-09 22:09:28 +0800
commitafe83af219c2146e022f6665cf30097b582d3e79 (patch)
tree74ce21d3ea64b1a433ffb723c0171a4071e42392 /ethereum.go
parent5a0bae1dae831818740a2f20ca308c4176f5201d (diff)
downloadgo-tangerine-afe83af219c2146e022f6665cf30097b582d3e79.tar.gz
go-tangerine-afe83af219c2146e022f6665cf30097b582d3e79.tar.zst
go-tangerine-afe83af219c2146e022f6665cf30097b582d3e79.zip
Moved seeding and moved manifest
Diffstat (limited to 'ethereum.go')
-rw-r--r--ethereum.go82
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))
}
}