小编Sha*_*zib的帖子

BloomFilter Python

我是python的新手,正尝试根据Bit torrent BEP 33创建bloomFilter。我已经创建了Bloom Filter,但这并不是我想要的。这是我需要的,但我还没有完全了解这种情况。如果有人可以在这里解释...

//fixed parameters

k = 2

m = 256*8

//the filter
byte[m/8] bloom   ## What is this part?

function insertIP(byte[] ip) {

    byte[20] hash = sha1(ip)

    int index1 = hash[0] | hash[1] << 8
    int index2 = hash[2] | hash[3] << 8

    // truncate index to m (11 bits required)
    index1 %= m  ## ?
    index2 %= m  ## ?

    // set bits at index1 and index2
    bloom[index1 / 8] |= 0x01 << index1 % 8 …
Run Code Online (Sandbox Code Playgroud)

python

4
推荐指数
1
解决办法
845
查看次数

标签 统计

python ×1