Search in sources :

Example 1 with FileGetContentsResponse

use of com.hederahashgraph.api.proto.java.FileGetContentsResponse in project hedera-services by hashgraph.

the class FeesAndRatesProvider method downloadFeeSchedule.

private void downloadFeeSchedule() throws Throwable {
    long queryFee = lookupDownloadFee(setup.feeScheduleId());
    FileGetContentsResponse response = downloadWith(queryFee, false, setup.feeScheduleId());
    byte[] bytes = response.getFileContents().getContents().toByteArray();
    CurrentAndNextFeeSchedule wrapper = CurrentAndNextFeeSchedule.parseFrom(bytes);
    feeSchedule = typePatching.withPatchedTypesIfNecessary(wrapper.getCurrentFeeSchedule());
    log.info("The fee schedule covers " + feeSchedule.getTransactionFeeScheduleList().size() + " ops.");
}
Also used : CurrentAndNextFeeSchedule(com.hederahashgraph.api.proto.java.CurrentAndNextFeeSchedule) FileGetContentsResponse(com.hederahashgraph.api.proto.java.FileGetContentsResponse)

Example 2 with FileGetContentsResponse

use of com.hederahashgraph.api.proto.java.FileGetContentsResponse in project hedera-services by hashgraph.

the class FeesAndRatesProvider method downloadRateSet.

private void downloadRateSet() throws Throwable {
    long queryFee = lookupDownloadFee(setup.exchangeRatesId());
    FileGetContentsResponse response = downloadWith(queryFee, false, setup.exchangeRatesId());
    byte[] bytes = response.getFileContents().getContents().toByteArray();
    rateSet = ExchangeRateSet.parseFrom(bytes);
    log.info("The exchange rates are :: " + rateSetAsString(rateSet));
}
Also used : FileGetContentsResponse(com.hederahashgraph.api.proto.java.FileGetContentsResponse)

Example 3 with FileGetContentsResponse

use of com.hederahashgraph.api.proto.java.FileGetContentsResponse in project hedera-services by hashgraph.

the class FeesAndRatesProvider method downloadWith.

private FileGetContentsResponse downloadWith(long queryFee, boolean costOnly, FileID fid) throws Throwable {
    int attemptsLeft = NUM_DOWNLOAD_ATTEMPTS;
    ResponseCodeEnum status;
    FileGetContentsResponse response;
    do {
        var payment = defaultPayerSponsored(queryFee);
        var query = downloadQueryWith(payment, costOnly, fid);
        response = clients.getFileSvcStub(setup.defaultNode(), setup.getConfigTLS()).getFileContent(query).getFileGetContents();
        status = response.getHeader().getNodeTransactionPrecheckCode();
        if (status == OK) {
            break;
        } else {
            log.warn("'{}' download attempt paid with {} got status {}, retrying...", asFileString(fid), toReadableString(payment), status);
        }
    } while (--attemptsLeft > 0);
    if (status != OK) {
        throw new IllegalStateException(String.format("Could not download '%s' final status %s", asFileString(fid), status));
    }
    return response;
}
Also used : ResponseCodeEnum(com.hederahashgraph.api.proto.java.ResponseCodeEnum) FileGetContentsResponse(com.hederahashgraph.api.proto.java.FileGetContentsResponse)

Aggregations

FileGetContentsResponse (com.hederahashgraph.api.proto.java.FileGetContentsResponse)3 CurrentAndNextFeeSchedule (com.hederahashgraph.api.proto.java.CurrentAndNextFeeSchedule)1 ResponseCodeEnum (com.hederahashgraph.api.proto.java.ResponseCodeEnum)1