예제 #1
0
파일: chain.py 프로젝트: tutty427/py-evm
 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)
예제 #2
0
 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)
예제 #3
0
 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)