src/main/java/org/hyperledger/fabric/sdk/Channel.java
/**
     * Query a peer in this channel for a Block by the block hash.
     *
     * @param peer      the Peer to query.
     * @param blockHash the hash of the Block in the chain.
     * @return the {@link BlockInfo} with the given block Hash
     * @throws InvalidArgumentException if the channel is shutdown or any of the arguments are not valid.
     * @throws ProposalException        if an error occurred processing the query.
     */
Query a peer in this channel for a Block by the block hash.
@param peer      the Peer to query.
@param blockHash the hash of the Block in the chain.
@return the  BlockInfo with the given block Hash
@throws InvalidArgumentException if the channel is shutdown or any of the arguments are not valid.
@throws ProposalException        if an error occurred processing the query.
Query a peer in this channel for a Block by the block hash . @param peer the Peer to query . @param blockHash the hash of the Block in the chain . @return the BlockInfo with the given block Hash @throws InvalidArgumentException if the channel is shutdown or any of the arguments are not valid . @throws ProposalException if an error occurred processing the query .
public BlockInfo queryBlockByHash(Peer peer, byte[] blockHash) throws InvalidArgumentException, ProposalException {
        checkChannelState();
        checkPeer(peer);
        if (blockHash == null) {
            throw new InvalidArgumentException("blockHash parameter is null.");
        }
        ProposalResponse proposalResponse;
        BlockInfo responseBlock;
        try {
            logger.debug("queryBlockByHash with hash : " + Hex.encodeHexString(blockHash) + "\n    to peer " + peer.getName() + " on channel " + name);
            QuerySCCRequest querySCCRequest = new QuerySCCRequest(client.getUserContext());
            querySCCRequest.setFcn(QuerySCCRequest.GETBLOCKBYHASH);
            querySCCRequest.setArgs(name);
            querySCCRequest.setArgBytes(new byte[][] {blockHash});
            Collection<ProposalResponse> proposalResponses = sendProposal(querySCCRequest, Collections.singletonList(peer));
            proposalResponse = proposalResponses.iterator().next();
            if (proposalResponse.getStatus().getStatus() != 200) {
                throw new PeerException(format("Unable to query block by hash %s %n.... for channel %s from peer %s \n    with message %s",
                        Hex.encodeHexString(blockHash),
                        name,
                        peer.getName(),
                        proposalResponse.getMessage()));
            }
            responseBlock = new BlockInfo(Block.parseFrom(proposalResponse.getProposalResponse().getResponse().getPayload()));
        } catch (Exception e) {
            String emsg = format("queryBlockByHash hash: %s peer %s channel %s error: %s",
                    Hex.encodeHexString(blockHash), peer.getName(), name, e.getMessage());
            logger.error(emsg, e);
            throw new ProposalException(emsg, e);
        }
        return responseBlock;
    }
public BlockInfo queryBlockByHash ( Peer peer , byte [ ] blockHash ) throws InvalidArgumentException , ProposalException { checkChannelState ( ) ; checkPeer ( peer ) ; if ( blockHash == null ) { throw new InvalidArgumentException ( "blockHash parameter is null." ) ; } ProposalResponse proposalResponse ; BlockInfo responseBlock ; try { logger . debug ( "queryBlockByHash with hash : " + Hex . encodeHexString ( blockHash ) + "\n    to peer " + peer . getName ( ) + " on channel " + name ) ; QuerySCCRequest querySCCRequest = new QuerySCCRequest ( client . getUserContext ( ) ) ; querySCCRequest . setFcn ( QuerySCCRequest . GETBLOCKBYHASH ) ; querySCCRequest . setArgs ( name ) ; querySCCRequest . setArgBytes ( new byte [ ] [ ] { blockHash } ) ; Collection < ProposalResponse > proposalResponses = sendProposal ( querySCCRequest , Collections . singletonList ( peer ) ) ; proposalResponse = proposalResponses . iterator ( ) . next ( ) ; if ( proposalResponse . getStatus ( ) . getStatus ( ) != 200 ) { throw new PeerException ( format ( "Unable to query block by hash %s %n.... for channel %s from peer %s \n    with message %s" , Hex . encodeHexString ( blockHash ) , name , peer . getName ( ) , proposalResponse . getMessage ( ) ) ) ; } responseBlock = new BlockInfo ( Block . parseFrom ( proposalResponse . getProposalResponse ( ) . getResponse ( ) . getPayload ( ) ) ) ; } catch ( Exception e ) { String emsg = format ( "queryBlockByHash hash: %s peer %s channel %s error: %s" , Hex . encodeHexString ( blockHash ) , peer . getName ( ) , name , e . getMessage ( ) ) ; logger . error ( emsg , e ) ; throw new ProposalException ( emsg , e ) ; } return responseBlock ; }
Query a peer in this channel for a Block by the block hash.
Query a peer in this channel for a Block by the block hash .