aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-09-22 22:28:28 +0800
committerobscuren <geffobscura@gmail.com>2014-09-22 22:28:28 +0800
commit9ed5b4d90e287de788d9079abab54578064864ba (patch)
treef1ccc95e7a528ae7ab241ab447bf7b3a4e6e9afd
parentb65f29f8faa20a93bd83c18232326c935cb16981 (diff)
downloadgo-tangerine-9ed5b4d90e287de788d9079abab54578064864ba.tar.gz
go-tangerine-9ed5b4d90e287de788d9079abab54578064864ba.tar.zst
go-tangerine-9ed5b4d90e287de788d9079abab54578064864ba.zip
Support C++ GetBlockHash by assuming empty = done
-rw-r--r--peer.go26
1 files 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()