async def _handle_get_block_bodies(self, peer: ETHPeer, msg: List[Hash32]) -> None: bodies = [] # Only serve up to eth.MAX_BODIES_FETCH items in every request. hashes = msg[:eth.MAX_BODIES_FETCH] for block_hash in hashes: header = await self.wait(self.chaindb.coro_get_block_header_by_hash(block_hash)) transactions = await self.wait( self.chaindb.coro_get_block_transactions(header, P2PTransaction)) uncles = await self.wait(self.chaindb.coro_get_block_uncles(header.uncles_hash)) bodies.append(BlockBody(transactions, uncles)) peer.sub_proto.send_block_bodies(bodies)
async def _handle_get_block_bodies(self, peer: ETHPeer, msg: List[Hash32]) -> None: bodies = [] # Only serve up to eth.MAX_BODIES_FETCH items in every request. hashes = msg[:eth.MAX_BODIES_FETCH] for block_hash in hashes: try: header = await self.wait(self.db.coro_get_block_header_by_hash(block_hash)) except HeaderNotFound: self.logger.debug("%s asked for block we don't have: %s", peer, block_hash) continue transactions = await self.wait( self.db.coro_get_block_transactions(header, BaseTransactionFields)) uncles = await self.wait(self.db.coro_get_block_uncles(header.uncles_hash)) bodies.append(BlockBody(transactions, uncles)) peer.sub_proto.send_block_bodies(bodies)
async def handle_get_block_bodies(self, peer: ETHPeer, block_hashes: List[Hash32]) -> None: self.logger.trace("%s requested bodies for %d blocks", peer, len(block_hashes)) chaindb = cast('AsyncChainDB', self.db) bodies = [] for block_hash in block_hashes: try: header = await self.wait(chaindb.coro_get_block_header_by_hash(block_hash)) except HeaderNotFound: self.logger.debug("%s asked for block we don't have: %s", peer, block_hash) continue transactions = await self.wait( chaindb.coro_get_block_transactions(header, BaseTransactionFields)) uncles = await self.wait(chaindb.coro_get_block_uncles(header.uncles_hash)) bodies.append(BlockBody(transactions, uncles)) self.logger.trace("Replying to %s with %d block bodies", peer, len(bodies)) peer.sub_proto.send_block_bodies(bodies)