Search in sources :

Example 1 with TransactionGetReceiptQuery

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

the class GetTxnReceiptAnswer method responseGiven.

@Override
public Response responseGiven(Query query, StateView view, ResponseCodeEnum validity, long cost) {
    TransactionGetReceiptQuery op = query.getTransactionGetReceipt();
    TransactionGetReceiptResponse.Builder opResponse = TransactionGetReceiptResponse.newBuilder();
    if (validity == OK) {
        var txnId = op.getTransactionID();
        var receipt = recordCache.getPriorityReceipt(txnId);
        if (receipt == null) {
            validity = RECEIPT_NOT_FOUND;
        } else {
            opResponse.setReceipt(receipt.toGrpc());
            if (op.getIncludeDuplicates()) {
                opResponse.addAllDuplicateTransactionReceipts(recordCache.getDuplicateReceipts(txnId));
            }
            if (op.getIncludeChildReceipts()) {
                opResponse.addAllChildTransactionReceipts(recordCache.getChildReceipts(txnId));
            }
        }
    }
    opResponse.setHeader(answerOnlyHeader(validity));
    return Response.newBuilder().setTransactionGetReceipt(opResponse).build();
}
Also used : TransactionGetReceiptQuery(com.hederahashgraph.api.proto.java.TransactionGetReceiptQuery) TransactionGetReceiptResponse(com.hederahashgraph.api.proto.java.TransactionGetReceiptResponse)

Example 2 with TransactionGetReceiptQuery

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

the class GetTxnReceiptAnswerTest method requiresNothing.

@Test
void requiresNothing() {
    // setup:
    TransactionGetReceiptQuery costAnswerOp = TransactionGetReceiptQuery.newBuilder().setHeader(QueryHeader.newBuilder().setResponseType(ResponseType.COST_ANSWER)).build();
    Query costAnswerQuery = Query.newBuilder().setTransactionGetReceipt(costAnswerOp).build();
    TransactionGetReceiptQuery answerOnlyOp = TransactionGetReceiptQuery.newBuilder().setHeader(QueryHeader.newBuilder().setResponseType(ANSWER_ONLY)).build();
    Query answerOnlyQuery = Query.newBuilder().setTransactionGetReceipt(answerOnlyOp).build();
    // expect:
    assertFalse(subject.requiresNodePayment(costAnswerQuery));
    assertFalse(subject.requiresNodePayment(answerOnlyQuery));
    assertFalse(subject.needsAnswerOnlyCost(answerOnlyQuery));
    assertFalse(subject.needsAnswerOnlyCost(costAnswerQuery));
}
Also used : TransactionGetReceiptQuery(com.hederahashgraph.api.proto.java.TransactionGetReceiptQuery) Query(com.hederahashgraph.api.proto.java.Query) TransactionGetReceiptQuery(com.hederahashgraph.api.proto.java.TransactionGetReceiptQuery) Test(org.junit.jupiter.api.Test)

Aggregations

TransactionGetReceiptQuery (com.hederahashgraph.api.proto.java.TransactionGetReceiptQuery)2 Query (com.hederahashgraph.api.proto.java.Query)1 TransactionGetReceiptResponse (com.hederahashgraph.api.proto.java.TransactionGetReceiptResponse)1 Test (org.junit.jupiter.api.Test)1