def get_chain_head(self): request = consensus_pb2.ConsensusChainHeadGetRequest() response_type = consensus_pb2.ConsensusChainHeadGetResponse response = self._send( request=request, message_type=Message.CONSENSUS_CHAIN_HEAD_GET_REQUEST, response_type=response_type) status = response.status if status == response_type.NO_CHAIN_HEAD: raise exceptions.NoChainHead() if status != response_type.OK: raise exceptions.ReceiveError( 'Failed with status {}'.format(status)) return Block(response.block)
def get_chain_head(self, parent_id=None, new_parent_id=None, is_new=False): request = consensus_pb2.ConsensusChainHeadGetRequest( parent_id=parent_id, new_parent_id=new_parent_id, is_new=is_new) response_type = consensus_pb2.ConsensusChainHeadGetResponse response = self._send( request=request, message_type=Message.CONSENSUS_CHAIN_HEAD_GET_REQUEST, response_type=response_type) status = response.status if status == response_type.NO_CHAIN_HEAD: raise exceptions.NoChainHead() if status == response_type.TOO_MANY_BRANCH: raise exceptions.TooManyBranch() if status != response_type.OK: raise exceptions.ReceiveError( 'Failed with status {}'.format(status)) #LOGGER.debug('get_chain_head: block=%s',response.block) return Block(response.block)