Support C++ GetBlockHash by assuming empty = done

This commit is contained in:
obscuren 2014-09-22 16:28:28 +02:00
parent b65f29f8fa
commit 9ed5b4d90e

View File

@ -362,12 +362,13 @@ clean:
} }
func formatMessage(msg *ethwire.Msg) (ret string) { 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 XXX Commented out because I need the log level here to determine
if i should or shouldn't generate this message if i should or shouldn't generate this message
*/ */
/*
switch msg.Type { switch msg.Type {
case ethwire.MsgPeersTy: case ethwire.MsgPeersTy:
ret += fmt.Sprintf("(%d entries)", msg.Data.Len()) ret += fmt.Sprintf("(%d entries)", msg.Data.Len())
@ -376,8 +377,9 @@ func formatMessage(msg *ethwire.Msg) (ret string) {
ret += fmt.Sprintf("(%d entries) %x - %x", msg.Data.Len(), b1.Hash()[0:4], b2.Hash()[0:4]) ret += fmt.Sprintf("(%d entries) %x - %x", msg.Data.Len(), b1.Hash()[0:4], b2.Hash()[0:4])
case ethwire.MsgBlockHashesTy: case ethwire.MsgBlockHashesTy:
h1, h2 := msg.Data.Get(0).Bytes(), msg.Data.Get(msg.Data.Len()-1).Bytes() 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]) ret += fmt.Sprintf("(%d entries) %x - %x", msg.Data.Len(), h1, h2)
} }
*/
return return
} }
@ -512,7 +514,7 @@ func (p *Peer) HandleInbound() {
p.lastBlockReceived = time.Now() p.lastBlockReceived = time.Now()
} }
if foundCommonHash { if foundCommonHash || msg.Data.Len() == 0 {
p.FetchBlocks() p.FetchBlocks()
} else { } else {
p.FetchHashes() p.FetchHashes()