MCPcopy Create free account
hub / github.com/Bitmessage/PyBitmessage / state_bm_header

Method state_bm_header

src/network/bmproto.py:70–85  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

68 self.object = None
69
70 def state_bm_header(self):
71 self.magic, self.command, self.payloadLength, self.checksum = protocol.Header.unpack(self.read_buf[:protocol.Header.size])
72 self.command = self.command.rstrip('\x00')
73 if self.magic != 0xE9BEB4D9:
74 # skip 1 byte in order to sync
75 self.set_state("bm_header", length=1)
76 self.bm_proto_reset()
77 logger.debug("Bad magic")
78 if self.socket.type == socket.SOCK_STREAM:
79 self.close_reason = "Bad magic"
80 self.set_state("close")
81 return False
82 if self.payloadLength > BMProto.maxMessageSize:
83 self.invalid = True
84 self.set_state("bm_command", length=protocol.Header.size, expectBytes=self.payloadLength)
85 return True
86
87 def state_bm_command(self):
88 self.payload = self.read_buf[:self.payloadLength]

Callers

nothing calls this directly

Calls 2

bm_proto_resetMethod · 0.95
set_stateMethod · 0.80

Tested by

no test coverage detected