MCPcopy
hub / github.com/petertodd/python-bitcoinlib / msg_deser

Method msg_deser

bitcoin/messages.py:129–154  ·  view source on GitHub ↗
(cls, f, protover=PROTO_VERSION)

Source from the content-addressed store, hash-verified

127
128 @classmethod
129 def msg_deser(cls, f, protover=PROTO_VERSION):
130 c = cls()
131 c.nVersion = struct.unpack(b"<i", ser_read(f, 4))[0]
132 if c.nVersion == 10300:
133 c.nVersion = 300
134 c.nServices = struct.unpack(b"<Q", ser_read(f, 8))[0]
135 c.nTime = struct.unpack(b"<q", ser_read(f, 8))[0]
136 c.addrTo = CAddress.stream_deserialize(f, True)
137 if c.nVersion >= 106:
138 c.addrFrom = CAddress.stream_deserialize(f, True)
139 c.nNonce = struct.unpack(b"<Q", ser_read(f, 8))[0]
140 c.strSubVer = VarStringSerializer.stream_deserialize(f)
141 if c.nVersion >= 209:
142 c.nStartingHeight = struct.unpack(b"<i", ser_read(f,4))[0]
143 else:
144 c.nStartingHeight = None
145 else:
146 c.addrFrom = None
147 c.nNonce = None
148 c.strSubVer = None
149 c.nStartingHeight = None
150 if c.nVersion >= 70001:
151 c.fRelay = struct.unpack(b"<B", ser_read(f,1))[0]
152 else:
153 c.fRelay = True
154 return c
155
156 def msg_ser(self, f):
157 f.write(struct.pack(b"<i", self.nVersion))

Callers

nothing calls this directly

Calls 2

ser_readFunction · 0.85
stream_deserializeMethod · 0.45

Tested by

no test coverage detected