MCPcopy Create free account
hub / github.com/ElementsProject/elements / build_message

Method build_message

test/functional/test_framework/p2p.py:283–295  ·  view source on GitHub ↗

Build a serialized P2P message

(self, message)

Source from the content-addressed store, hash-verified

281 # Class utility methods
282
283 def build_message(self, message):
284 """Build a serialized P2P message"""
285 msgtype = message.msgtype
286 data = message.serialize()
287 tmsg = self.magic_bytes
288 tmsg += msgtype
289 tmsg += b"\x00" * (12 - len(msgtype))
290 tmsg += struct.pack("<I", len(data))
291 th = sha256(data)
292 h = sha256(th)
293 tmsg += h[:4]
294 tmsg += data
295 return tmsg
296
297 def _log_message(self, direction, msg):
298 """Logs a message being sent or received over the connection."""

Callers 7

send_messageMethod · 0.95
test_bufferMethod · 0.45
test_magic_bytesMethod · 0.45
test_checksumMethod · 0.45
test_sizeMethod · 0.45
test_msgtypeMethod · 0.45
test_addrv2Method · 0.45

Calls 2

sha256Function · 0.90
serializeMethod · 0.45

Tested by 6

test_bufferMethod · 0.36
test_magic_bytesMethod · 0.36
test_checksumMethod · 0.36
test_sizeMethod · 0.36
test_msgtypeMethod · 0.36
test_addrv2Method · 0.36