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.");
}
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));
}
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;
}
Aggregations