MCPcopy Index your code
hub / github.com/jimmysong/programmingbitcoin / filterload

Method filterload

code-ch13/bloomfilter.py:39–53  ·  view source on GitHub ↗

Return the filterload message

(self, flag=1)

Source from the content-addressed store, hash-verified

37 return bit_field_to_bytes(self.bit_field)
38
39 def filterload(self, flag=1):
40 '''Return the filterload message'''
41 # start the payload with the size of the filter in bytes
42 payload = encode_varint(self.size)
43 # next add the bit field using self.filter_bytes()
44 payload += self.filter_bytes()
45 # function count is 4 bytes little endian
46 payload += int_to_little_endian(self.function_count, 4)
47 # tweak is 4 bytes little endian
48 payload += int_to_little_endian(self.tweak, 4)
49 # flag is 1 byte little endian
50 payload += int_to_little_endian(flag, 1)
51 # return a GenericMessage whose command is b'filterload'
52 # and payload is what we've calculated
53 return GenericMessage(b'filterload', payload)
54
55
56class BloomFilterTest(TestCase):

Callers 1

test_filterloadMethod · 0.95

Calls 4

filter_bytesMethod · 0.95
encode_varintFunction · 0.90
int_to_little_endianFunction · 0.90
GenericMessageClass · 0.90

Tested by 1

test_filterloadMethod · 0.76