Skip to content

Commit

Permalink
s8 bloomfilter genericmessage
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmysong committed Apr 16, 2019
1 parent f5854e5 commit 329102b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 3 additions & 1 deletion session8/bloomfilter.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from unittest import TestCase

from helper import bit_field_to_bytes, encode_varint, int_to_little_endian, murmur3
from network import GenericMessage


BIP37_CONSTANT = 0xfba4c795
Expand All @@ -27,12 +28,13 @@ def filter_bytes(self):
return bit_field_to_bytes(self.bit_field)

def filterload(self, flag=1):
'''Return the payload that goes in a filterload message'''
'''Return a network message whose command is filterload'''
# encode_varint self.size
# next is the self.filter_bytes()
# function count is 4 bytes little endian
# tweak is 4 bytes little endian
# flag is 1 byte little endian
# return a GenericMessage with b'filterload' as the command
raise NotImplementedError


Expand Down
3 changes: 2 additions & 1 deletion session8/complete/bloomfilter.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def filter_bytes(self):
return bit_field_to_bytes(self.bit_field)

def filterload(self, flag=1):
'''Return the payload that goes in a filterload message'''
'''Return a network message whose command is filterload'''
# encode_varint self.size
payload = encode_varint(self.size)
# next is the self.filter_bytes()
Expand All @@ -43,6 +43,7 @@ def filterload(self, flag=1):
payload += int_to_little_endian(self.tweak, 4)
# flag is 1 byte little endian
payload += int_to_little_endian(flag, 1)
# return a GenericMessage with b'filterload' as the command
return GenericMessage(b'filterload', payload)


Expand Down

0 comments on commit 329102b

Please sign in to comment.