use of com.hederahashgraph.api.proto.java.Response in project hedera-services by hashgraph.
the class HapiGetFileContents method lookupCostWith.
@Override
protected long lookupCostWith(HapiApiSpec spec, Transaction payment) throws Throwable {
Query query = getFileContentQuery(spec, payment, true);
Response response = spec.clients().getFileSvcStub(targetNodeFor(spec), useTls).getFileContent(query);
return costFrom(response);
}
use of com.hederahashgraph.api.proto.java.Response in project hedera-services by hashgraph.
the class HapiTxnOp method statusResponse.
private Response statusResponse(HapiApiSpec spec, Query receiptQuery) throws Throwable {
long before = System.currentTimeMillis();
Response response = null;
int allowedUnrecognizedExceptions = 10;
while (response == null) {
try {
var cryptoSvcStub = spec.clients().getCryptoSvcStub(targetNodeFor(spec), useTls);
if (cryptoSvcStub == null) {
response = UNKNOWN_RESPONSE;
} else {
response = cryptoSvcStub.getTransactionReceipts(receiptQuery);
}
} catch (Exception e) {
var msg = e.toString();
if (isRecognizedRecoverable(msg)) {
log.info("Recognized recoverable runtime exception {}, retrying status resolution...", msg);
continue;
}
log.warn("({}) Status resolution failed with unrecognized exception", Thread.currentThread().getName(), e);
allowedUnrecognizedExceptions--;
if (allowedUnrecognizedExceptions == 0) {
response = UNKNOWN_RESPONSE;
}
}
}
long after = System.currentTimeMillis();
considerRecordingAdHocReceiptQueryStats(spec.registry(), after - before);
return response;
}
use of com.hederahashgraph.api.proto.java.Response in project hedera-services by hashgraph.
the class HapiTxnOp method resolvedStatusOfSubmission.
private ResponseCodeEnum resolvedStatusOfSubmission(HapiApiSpec spec) throws Throwable {
long delayMS = spec.setup().statusPreResolvePauseMs();
long elapsedMS = System.currentTimeMillis() - submitTime;
if (elapsedMS <= delayMS) {
pause(delayMS - elapsedMS);
}
long beginWait = Instant.now().toEpochMilli();
Query receiptQuery = txnReceiptQueryFor(extractTxnId(txnSubmitted));
do {
Response response = statusResponse(spec, receiptQuery);
lastReceipt = response.getTransactionGetReceipt().getReceipt();
ResponseCodeEnum statusNow = lastReceipt.getStatus();
if (acceptAnyStatus) {
expectedStatus = Optional.of(statusNow);
return statusNow;
} else if (statusNow != UNKNOWN) {
if (acceptAnyKnownStatus) {
expectedStatus = Optional.of(statusNow);
}
return statusNow;
}
pause(spec.setup().statusWaitSleepMs());
} while ((Instant.now().toEpochMilli() - beginWait) < spec.setup().statusWaitTimeoutMs());
return UNKNOWN;
}
use of com.hederahashgraph.api.proto.java.Response in project hedera-services by hashgraph.
the class HapiGetAccountNftInfos method lookupCostWith.
@Override
protected long lookupCostWith(HapiApiSpec spec, Transaction payment) throws Throwable {
Query query = getAccountNftInfosQuery(spec, payment, true);
Response response = spec.clients().getTokenSvcStub(targetNodeFor(spec), useTls).getAccountNftInfos(query);
return costFrom(response);
}
use of com.hederahashgraph.api.proto.java.Response in project hedera-services by hashgraph.
the class HapiGetTokenInfo method lookupCostWith.
@Override
protected long lookupCostWith(HapiApiSpec spec, Transaction payment) throws Throwable {
Query query = getTokenInfoQuery(spec, payment, true);
Response response = spec.clients().getTokenSvcStub(targetNodeFor(spec), useTls).getTokenInfo(query);
return costFrom(response);
}
Aggregations