From 35f4bb96f313f4f04e70d1cf135be3a4759a8179 Mon Sep 17 00:00:00 2001 From: obscuren Date: Fri, 9 Jan 2015 16:44:09 +0100 Subject: Limit hashes. Closes #249 --- eth/protocol.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/eth/protocol.go b/eth/protocol.go index c9a5dea8d..24a0f0a8e 100644 --- a/eth/protocol.go +++ b/eth/protocol.go @@ -67,6 +67,8 @@ type newBlockMsgData struct { TD *big.Int } +const maxHashes = 255 + type getBlockHashesMsgData struct { Hash []byte Amount uint64 @@ -139,6 +141,11 @@ func (self *ethProtocol) handle() error { if err := msg.Decode(&request); err != nil { return self.protoError(ErrDecode, "->msg %v: %v", msg, err) } + + //request.Amount = uint64(math.Min(float64(maxHashes), float64(request.Amount))) + if request.Amount > maxHashes { + request.Amount = maxHashes + } hashes := self.chainManager.GetBlockHashesFromHash(request.Hash, request.Amount) return p2p.EncodeMsg(self.rw, BlockHashesMsg, ethutil.ByteSliceToInterface(hashes)...) -- cgit v1.2.3