From 9ed5b4d90e287de788d9079abab54578064864ba Mon Sep 17 00:00:00 2001 From: obscuren Date: Mon, 22 Sep 2014 16:28:28 +0200 Subject: Support C++ GetBlockHash by assuming empty = done --- peer.go | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/peer.go b/peer.go index 8c04864d0..67bf4e555 100644 --- a/peer.go +++ b/peer.go @@ -362,22 +362,24 @@ clean: } func formatMessage(msg *ethwire.Msg) (ret string) { - ret = fmt.Sprintf("%v ", msg.Type) + ret = fmt.Sprintf("%v %v", msg.Type, msg.Data) /* XXX Commented out because I need the log level here to determine if i should or shouldn't generate this message */ - switch msg.Type { - case ethwire.MsgPeersTy: - ret += fmt.Sprintf("(%d entries)", msg.Data.Len()) - case ethwire.MsgBlockTy: - b1, b2 := ethchain.NewBlockFromRlpValue(msg.Data.Get(0)), ethchain.NewBlockFromRlpValue(msg.Data.Get(msg.Data.Len()-1)) - ret += fmt.Sprintf("(%d entries) %x - %x", msg.Data.Len(), b1.Hash()[0:4], b2.Hash()[0:4]) - case ethwire.MsgBlockHashesTy: - h1, h2 := msg.Data.Get(0).Bytes(), msg.Data.Get(msg.Data.Len()-1).Bytes() - ret += fmt.Sprintf("(%d entries) %x - %x", msg.Data.Len(), h1[0:4], h2[0:4]) - } + /* + switch msg.Type { + case ethwire.MsgPeersTy: + ret += fmt.Sprintf("(%d entries)", msg.Data.Len()) + case ethwire.MsgBlockTy: + b1, b2 := ethchain.NewBlockFromRlpValue(msg.Data.Get(0)), ethchain.NewBlockFromRlpValue(msg.Data.Get(msg.Data.Len()-1)) + ret += fmt.Sprintf("(%d entries) %x - %x", msg.Data.Len(), b1.Hash()[0:4], b2.Hash()[0:4]) + case ethwire.MsgBlockHashesTy: + h1, h2 := msg.Data.Get(0).Bytes(), msg.Data.Get(msg.Data.Len()-1).Bytes() + ret += fmt.Sprintf("(%d entries) %x - %x", msg.Data.Len(), h1, h2) + } + */ return } @@ -512,7 +514,7 @@ func (p *Peer) HandleInbound() { p.lastBlockReceived = time.Now() } - if foundCommonHash { + if foundCommonHash || msg.Data.Len() == 0 { p.FetchBlocks() } else { p.FetchHashes() -- cgit v1.2.3 From 16871ae2b49fb2a8fad3848e3184c8ab87c7f67a Mon Sep 17 00:00:00 2001 From: obscuren Date: Mon, 22 Sep 2014 16:28:49 +0200 Subject: New Peer server --- ethereum.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ethereum.go b/ethereum.go index 4cf1ce9e7..a54399921 100644 --- a/ethereum.go +++ b/ethereum.go @@ -25,7 +25,7 @@ import ( const ( seedTextFileUri string = "http://www.ethereum.org/servers.poc3.txt" - seedNodeAddress = "54.76.56.74:30303" + seedNodeAddress = "poc-6.ethdev.com:30303" ) var ethlogger = ethlog.NewLogger("SERV") @@ -208,6 +208,7 @@ func (s *Ethereum) ProcessPeerList(addrs []string) { } func (s *Ethereum) ConnectToPeer(addr string) error { + fmt.Println("ConnectToPeer", addr) if s.peers.Len() < s.MaxPeers { var alreadyConnected bool -- cgit v1.2.3 From 1bc815e0b1d3fb6f47f8747e607a03f6d8a25ac2 Mon Sep 17 00:00:00 2001 From: obscuren Date: Mon, 22 Sep 2014 16:30:30 +0200 Subject: Remove log --- ethereum.go | 1 - 1 file changed, 1 deletion(-) diff --git a/ethereum.go b/ethereum.go index a54399921..79e722c26 100644 --- a/ethereum.go +++ b/ethereum.go @@ -208,7 +208,6 @@ func (s *Ethereum) ProcessPeerList(addrs []string) { } func (s *Ethereum) ConnectToPeer(addr string) error { - fmt.Println("ConnectToPeer", addr) if s.peers.Len() < s.MaxPeers { var alreadyConnected bool -- cgit v1.2.3 From 2ae3bda029ec91e02fb164fd53175ad78d45a0ba Mon Sep 17 00:00:00 2001 From: obscuren Date: Mon, 22 Sep 2014 18:15:10 +0200 Subject: Increased from 200 nano to milliseconds --- ethwire/messaging.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ethwire/messaging.go b/ethwire/messaging.go index b1cefc0ae..2b3836e9c 100644 --- a/ethwire/messaging.go +++ b/ethwire/messaging.go @@ -109,9 +109,10 @@ func ReadMessages(conn net.Conn) (msgs []*Msg, err error) { } } + fmt.Println(n, len(buff)) if n == 0 && len(buff) == 0 { // If there's nothing on the wire wait for a bit - time.Sleep(200) + time.Sleep(200 * time.Millisecond) continue } -- cgit v1.2.3 From 7d08e4f7d14600ee4ed38fc9d435e9c2e0e0fdac Mon Sep 17 00:00:00 2001 From: obscuren Date: Mon, 22 Sep 2014 18:15:32 +0200 Subject: Remove log --- ethwire/messaging.go | 1 - 1 file changed, 1 deletion(-) diff --git a/ethwire/messaging.go b/ethwire/messaging.go index 2b3836e9c..2ef53c003 100644 --- a/ethwire/messaging.go +++ b/ethwire/messaging.go @@ -109,7 +109,6 @@ func ReadMessages(conn net.Conn) (msgs []*Msg, err error) { } } - fmt.Println(n, len(buff)) if n == 0 && len(buff) == 0 { // If there's nothing on the wire wait for a bit time.Sleep(200 * time.Millisecond) -- cgit v1.2.3