diff options
author | obscuren <geffobscura@gmail.com> | 2014-02-12 01:46:28 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2014-02-12 01:46:28 +0800 |
commit | 02acef23d595dc2bc95295bab63658addf664aaf (patch) | |
tree | b91e7a59b788520a995cc37cbc1a8a1621265081 | |
parent | 5a83114efd96bb8debeb3a3fccc3e054069e5400 (diff) | |
download | dexon-02acef23d595dc2bc95295bab63658addf664aaf.tar.gz dexon-02acef23d595dc2bc95295bab63658addf664aaf.tar.zst dexon-02acef23d595dc2bc95295bab63658addf664aaf.zip |
Interop!
-rw-r--r-- | ethereum.go | 31 | ||||
-rw-r--r-- | peer.go | 7 |
2 files changed, 21 insertions, 17 deletions
diff --git a/ethereum.go b/ethereum.go index cac442dfc..6ace58308 100644 --- a/ethereum.go +++ b/ethereum.go @@ -60,8 +60,8 @@ type Ethereum struct { } func New(caps Caps, usePnp bool) (*Ethereum, error) { - db, err := ethdb.NewLDBDatabase() - //db, err := ethdb.NewMemDatabase() + //db, err := ethdb.NewLDBDatabase() + db, err := ethdb.NewMemDatabase() if err != nil { return nil, err } @@ -246,19 +246,22 @@ func (s *Ethereum) Start() { // Start the tx pool s.TxPool.Start() - resp, err := http.Get("http://www.ethereum.org/servers.poc2.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 - } + if ethutil.Config.Seed { + // Testnet seed bootstrapping + resp, err := http.Get("http://www.ethereum.org/servers.poc2.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)) + } } func (s *Ethereum) peerHandler(listener net.Listener) { @@ -204,6 +204,7 @@ func (p *Peer) HandleOutbound() { // The ping timer. Makes sure that every 2 minutes a ping is send to the peer pingTimer := time.NewTicker(2 * time.Minute) serviceTimer := time.NewTicker(5 * time.Minute) + out: for { select { @@ -442,7 +443,7 @@ func (p *Peer) pushHandshake() error { clientId := fmt.Sprintf("/Ethereum(G) v%s/%s", ethutil.Config.Ver, runtime.GOOS) msg := ethwire.NewMessage(ethwire.MsgHandshakeTy, []interface{}{ - uint32(3), uint32(0), clientId, byte(p.caps), p.port, pubkey, + uint32(4), uint32(0), clientId, byte(p.caps), p.port, pubkey, }) p.QueueMessage(msg) @@ -469,8 +470,8 @@ func (p *Peer) pushPeers() { func (p *Peer) handleHandshake(msg *ethwire.Msg) { c := msg.Data - if c.Get(0).AsUint() != 3 { - log.Println("Invalid peer version. Require protocol v3") + if c.Get(0).AsUint() != 4 { + log.Println("Invalid peer version. Require protocol v4") p.Stop() return } |