Exemple #1
0
 async def get_block(self, header_hash) -> Optional[FullBlock]:
     try:
         response = await self.fetch("get_block",
                                     {"header_hash": header_hash.hex()})
     except Exception:
         return None
     return FullBlock.from_json_dict(response["block"])
Exemple #2
0
 async def get_all_block(self, start: uint32,
                         end: uint32) -> List[FullBlock]:
     response = await self.fetch("get_blocks", {
         "start": start,
         "end": end,
         "exclude_header_hash": True
     })
     return [FullBlock.from_json_dict(r) for r in response["blocks"]]
 async def get_blocks(self,
                      start: int,
                      end: int,
                      exclude_reorged: bool = False) -> List[FullBlock]:
     response = await self.fetch(
         "get_blocks", {
             "start": start,
             "end": end,
             "exclude_header_hash": True,
             "exclude_reorged": exclude_reorged
         })
     return [
         FullBlock.from_json_dict(block) for block in response["blocks"]
     ]
Exemple #4
0
    def test_json(self):
        block = bt.create_genesis_block(test_constants, bytes([0] * 32), b"0")

        dict_block = block.to_json_dict()
        assert FullBlock.from_json_dict(dict_block) == block