コード例 #1
0
 def received_blocks_request(
     self, peer: Peer, payload: BlocksRequestPayload
 ) -> None:
     f_diff = FrontierDiff.from_bytes(payload.frontier_diff)
     chain_id = payload.subcom_id
     vals_to_request = set()
     self.logger.debug(
         "Received block request %s from peer %s. Audit chain: %s",
         f_diff,
         peer,
         chain_id.startswith(b"w"),
     )
     blocks = self.persistence.get_block_blobs_by_frontier_diff(
         chain_id, f_diff, vals_to_request
     )
     self.logger.debug(
         "Sending %s blocks to peer %s. Audit chain %s",
         len(blocks),
         peer,
         chain_id.startswith(b"w"),
     )
     for block in blocks:
         self.send_packet(peer, RawBlockPayload(block))
コード例 #2
0
ファイル: test_frontiers.py プロジェクト: devos50/noodle
def test_frontier_diff_bytes_convert(val):
    f = FrontierDiff(val.holes, val.conflicts)
    assert FrontierDiff.from_bytes(f.to_bytes()) == f