async def make_raw_header(self, b): pbh = b.get('previousblockhash') if pbh is None: pbh = '0' * 64 return b''.join([ pack('<L', b.get('version')), hex_str_to_hash(pbh), hex_str_to_hash(b.get('merkleroot')), pack('<L', self.timestamp_safe(b['time'])), pack('<L', int(b.get('bits'), 16)), pack('<L', int(b.get('nonce'))) ])
async def _refresh_hashes(self, synchronized_event): """Refresh our view of the daemon's mempool.""" while True: height = self.api.cached_height() hex_hashes = await self.api.mempool_hashes() if height != await self.api.height(): continue hashes = {hex_str_to_hash(hh) for hh in hex_hashes} async with self.lock: touched = await self._process_mempool(hashes) synchronized_event.set() synchronized_event.clear() await self.api.on_mempool(touched, height) await sleep(self.refresh_secs)