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

Method serialize

code-ch13/network.py:246–256  ·  view source on GitHub ↗

Serialize this message to send over the network

(self)

Source from the content-addressed store, hash-verified

244 self.end_block = end_block
245
246 def serialize(self):
247 '''Serialize this message to send over the network'''
248 # protocol version is 4 bytes little-endian
249 result = int_to_little_endian(self.version, 4)
250 # number of hashes is a varint
251 result += encode_varint(self.num_hashes)
252 # start block is in little-endian
253 result += self.start_block[::-1]
254 # end block is also in little-endian
255 result += self.end_block[::-1]
256 return result
257
258
259class GetHeadersMessageTest(TestCase):

Callers 1

test_serializeMethod · 0.95

Calls 2

int_to_little_endianFunction · 0.90
encode_varintFunction · 0.90

Tested by 1

test_serializeMethod · 0.76