Return the filterload message
(self, flag=1)
| 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 | |
| 56 | class BloomFilterTest(TestCase): |