From c8627cbee476dcb0c933b7ae24a1eca571de76ab Mon Sep 17 00:00:00 2001 From: pedro martelletto Date: Tue, 10 Jan 2017 12:53:21 +0000 Subject: [PATCH] Use a harcoded key to generate filters Pointed out by alex@. Using a dummy key for now. --- server.go | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-) diff --git a/server.go b/server.go index 3c3df7c14..55594b5a1 100644 --- a/server.go +++ b/server.go @@ -771,8 +771,7 @@ func (sp *serverPeer) OnGetCBFilter(_ *peer.Peer, msg *wire.MsgGetCBFilter) { P := uint8(20) // collision probability for i := 0; i < gcs.KeySize; i += 4 { - binary.BigEndian.PutUint32(key[i:], - randomUint32Number(math.MaxUint32)) + binary.BigEndian.PutUint32(key[i:], uint32(0xcafebabe)) } filter, err := gcs.BuildGCSFilter(P, key, txHashes) @@ -1013,24 +1012,6 @@ func randomUint16Number(max uint16) uint16 { } } -// randomUint32Number returns a random uint32 in a specified input range. Note -// that the range is in zeroth ordering; if you pass it 1800, you will get -// values from 0 to 1800. -func randomUint32Number(max uint32) uint32 { - // In order to avoid modulo bias and ensure every possible outcome in - // [0, max) has equal probability, the random number must be sampled - // from a random source that has a range limited to a multiple of the - // modulus. - var randomNumber uint32 - var limitRange = (math.MaxUint32 / max) * max - for { - binary.Read(rand.Reader, binary.LittleEndian, &randomNumber) - if randomNumber < limitRange { - return (randomNumber % max) - } - } -} - // AddRebroadcastInventory adds 'iv' to the list of inventories to be // rebroadcasted at random intervals until they show up in a block. func (s *server) AddRebroadcastInventory(iv *wire.InvVect, data interface{}) {