| 220 | |
| 221 | |
| 222 | class CInv: |
| 223 | __slots__ = ("hash", "type") |
| 224 | |
| 225 | typemap = { |
| 226 | 0: "Error", |
| 227 | 1: "TX", |
| 228 | 2: "Block", |
| 229 | 1|MSG_WITNESS_FLAG: "WitnessTx", |
| 230 | 2|MSG_WITNESS_FLAG : "WitnessBlock", |
| 231 | 4: "CompactBlock" |
| 232 | } |
| 233 | |
| 234 | def __init__(self, t=0, h=0): |
| 235 | self.type = t |
| 236 | self.hash = h |
| 237 | |
| 238 | def deserialize(self, f): |
| 239 | self.type = struct.unpack("<i", f.read(4))[0] |
| 240 | self.hash = deser_uint256(f) |
| 241 | |
| 242 | def serialize(self): |
| 243 | r = b"" |
| 244 | r += struct.pack("<i", self.type) |
| 245 | r += ser_uint256(self.hash) |
| 246 | return r |
| 247 | |
| 248 | def __repr__(self): |
| 249 | return "CInv(type=%s hash=%064x)" \ |
| 250 | % (self.typemap[self.type], self.hash) |
| 251 | |
| 252 | |
| 253 | class CBlockLocator: |
no outgoing calls