From e51eeb81044c5cfc9416da4edce6da25b90acdb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Szil=C3=A1gyi?= Date: Tue, 15 Dec 2015 19:22:48 +0200 Subject: eth: fix #2076, where end of hash query was interpreted number query --- eth/handler.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'eth/handler.go') diff --git a/eth/handler.go b/eth/handler.go index d8c5b4b64..d04f79105 100644 --- a/eth/handler.go +++ b/eth/handler.go @@ -372,6 +372,8 @@ func (pm *ProtocolManager) handleMsg(p *peer) error { if err := msg.Decode(&query); err != nil { return errResp(ErrDecode, "%v: %v", msg, err) } + hashMode := query.Origin.Hash != (common.Hash{}) + // Gather headers until the fetch or network limits is reached var ( bytes common.StorageSize @@ -381,7 +383,7 @@ func (pm *ProtocolManager) handleMsg(p *peer) error { for !unknown && len(headers) < int(query.Amount) && bytes < softResponseLimit && len(headers) < downloader.MaxHeaderFetch { // Retrieve the next header satisfying the query var origin *types.Header - if query.Origin.Hash != (common.Hash{}) { + if hashMode { origin = pm.blockchain.GetHeader(query.Origin.Hash) } else { origin = pm.blockchain.GetHeaderByNumber(query.Origin.Number) -- cgit v1.2.3