Search in sources :

Example 61 with Response

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);
}
Also used : Response(com.hederahashgraph.api.proto.java.Response) Query(com.hederahashgraph.api.proto.java.Query) FileGetContentsQuery(com.hederahashgraph.api.proto.java.FileGetContentsQuery)

Example 62 with 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;
}
Also used : TransactionGetReceiptResponse(com.hederahashgraph.api.proto.java.TransactionGetReceiptResponse) TransactionResponse(com.hederahashgraph.api.proto.java.TransactionResponse) Response(com.hederahashgraph.api.proto.java.Response) HapiTxnCheckStateException(com.hedera.services.bdd.spec.exceptions.HapiTxnCheckStateException) StatusRuntimeException(io.grpc.StatusRuntimeException) HapiTxnPrecheckStateException(com.hedera.services.bdd.spec.exceptions.HapiTxnPrecheckStateException)

Example 63 with 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;
}
Also used : TransactionGetReceiptResponse(com.hederahashgraph.api.proto.java.TransactionGetReceiptResponse) TransactionResponse(com.hederahashgraph.api.proto.java.TransactionResponse) Response(com.hederahashgraph.api.proto.java.Response) ResponseCodeEnum(com.hederahashgraph.api.proto.java.ResponseCodeEnum) Query(com.hederahashgraph.api.proto.java.Query)

Example 64 with Response

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);
}
Also used : Response(com.hederahashgraph.api.proto.java.Response) Query(com.hederahashgraph.api.proto.java.Query) TokenGetAccountNftInfosQuery(com.hederahashgraph.api.proto.java.TokenGetAccountNftInfosQuery)

Example 65 with 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);
}
Also used : Response(com.hederahashgraph.api.proto.java.Response) TokenGetInfoQuery(com.hederahashgraph.api.proto.java.TokenGetInfoQuery) Query(com.hederahashgraph.api.proto.java.Query)

Aggregations

Response (com.hederahashgraph.api.proto.java.Response)114 Query (com.hederahashgraph.api.proto.java.Query)96 Test (org.junit.jupiter.api.Test)87 FileGetInfoResponse (com.hederahashgraph.api.proto.java.FileGetInfoResponse)9 ByteString (com.google.protobuf.ByteString)8 ContractCallLocalQuery (com.hederahashgraph.api.proto.java.ContractCallLocalQuery)8 TokenGetNftInfoQuery (com.hederahashgraph.api.proto.java.TokenGetNftInfoQuery)8 TokenGetNftInfoResponse (com.hederahashgraph.api.proto.java.TokenGetNftInfoResponse)8 TransactionGetReceiptResponse (com.hederahashgraph.api.proto.java.TransactionGetReceiptResponse)8 ContractCallLocalResponse (com.hederahashgraph.api.proto.java.ContractCallLocalResponse)7 ContractGetInfoQuery (com.hederahashgraph.api.proto.java.ContractGetInfoQuery)7 ContractGetInfoResponse (com.hederahashgraph.api.proto.java.ContractGetInfoResponse)7 NetworkGetExecutionTimeQuery (com.hederahashgraph.api.proto.java.NetworkGetExecutionTimeQuery)7 NetworkGetExecutionTimeResponse (com.hederahashgraph.api.proto.java.NetworkGetExecutionTimeResponse)7 ResponseCodeEnum (com.hederahashgraph.api.proto.java.ResponseCodeEnum)7 ScheduleGetInfoQuery (com.hederahashgraph.api.proto.java.ScheduleGetInfoQuery)7 ScheduleGetInfoResponse (com.hederahashgraph.api.proto.java.ScheduleGetInfoResponse)7 TokenGetInfoQuery (com.hederahashgraph.api.proto.java.TokenGetInfoQuery)7 TokenGetInfoResponse (com.hederahashgraph.api.proto.java.TokenGetInfoResponse)7 HashMap (java.util.HashMap)7