(cls, stream)
| 272 | |
| 273 | @classmethod |
| 274 | def parse(cls, stream): |
| 275 | # number of headers is in a varint |
| 276 | num_headers = read_varint(stream) |
| 277 | # initialize the blocks array |
| 278 | blocks = [] |
| 279 | # loop through number of headers times |
| 280 | for _ in range(num_headers): |
| 281 | # add a block to the blocks array by parsing the stream |
| 282 | blocks.append(Block.parse(stream)) |
| 283 | # read the next varint (num_txs) |
| 284 | num_txs = read_varint(stream) |
| 285 | # num_txs should be 0 or raise a RuntimeError |
| 286 | if num_txs != 0: |
| 287 | raise RuntimeError('number of txs not 0') |
| 288 | # return a class instance |
| 289 | return cls(blocks) |
| 290 | |
| 291 | |
| 292 | class HeadersMessageTest(TestCase): |
nothing calls this directly
no test coverage detected