Search in sources :

Example 1 with GetBlockRequest

use of com.amazonaws.services.qldb.model.GetBlockRequest in project amazon-qldb-dmv-sample-java by aws-samples.

the class GetBlock method getBlockWithProof.

public static GetBlockResult getBlockWithProof(String ledgerName, BlockAddress blockAddress, BlockAddress tipBlockAddress) {
    log.info("Let's get the block for block address {}, digest tip address {}, for the ledger named {}.", blockAddress, tipBlockAddress, ledgerName);
    try {
        GetBlockRequest request = new GetBlockRequest().withName(ledgerName).withBlockAddress(new ValueHolder().withIonText(Constants.MAPPER.writeValueAsIonValue(blockAddress).toString())).withDigestTipAddress(new ValueHolder().withIonText(Constants.MAPPER.writeValueAsIonValue(tipBlockAddress).toString()));
        GetBlockResult result = client.getBlock(request);
        log.info("Success. GetBlock: {}.", QldbStringUtils.toUnredactedString(result));
        return result;
    } catch (IOException ioe) {
        throw new IllegalStateException(ioe);
    }
}
Also used : GetBlockResult(com.amazonaws.services.qldb.model.GetBlockResult) IOException(java.io.IOException) ValueHolder(com.amazonaws.services.qldb.model.ValueHolder) GetBlockRequest(com.amazonaws.services.qldb.model.GetBlockRequest)

Example 2 with GetBlockRequest

use of com.amazonaws.services.qldb.model.GetBlockRequest in project amazon-qldb-dmv-sample-java by aws-samples.

the class GetBlock method getBlock.

public static GetBlockResult getBlock(String ledgerName, BlockAddress blockAddress) {
    log.info("Let's get the block for block address {} of the ledger named {}.", blockAddress, ledgerName);
    try {
        GetBlockRequest request = new GetBlockRequest().withName(ledgerName).withBlockAddress(new ValueHolder().withIonText(Constants.MAPPER.writeValueAsIonValue(blockAddress).toString()));
        GetBlockResult result = client.getBlock(request);
        log.info("Success. GetBlock: {}.", QldbStringUtils.toUnredactedString(result));
        return result;
    } catch (IOException ioe) {
        throw new IllegalStateException(ioe);
    }
}
Also used : GetBlockResult(com.amazonaws.services.qldb.model.GetBlockResult) IOException(java.io.IOException) ValueHolder(com.amazonaws.services.qldb.model.ValueHolder) GetBlockRequest(com.amazonaws.services.qldb.model.GetBlockRequest)

Aggregations

GetBlockRequest (com.amazonaws.services.qldb.model.GetBlockRequest)2 GetBlockResult (com.amazonaws.services.qldb.model.GetBlockResult)2 ValueHolder (com.amazonaws.services.qldb.model.ValueHolder)2 IOException (java.io.IOException)2