Search in sources :

Example 1 with FeeComponents

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

the class FeeBuilder method getFeeDataMatrices.

public static FeeData getFeeDataMatrices(FeeComponents feeComponents, int payerVpt, long rbsNetwork) {
    long rbh = Math.max(feeComponents.getRbh() > 0 ? 1 : 0, feeComponents.getRbh() / HRS_DIVISOR);
    long sbh = Math.max(feeComponents.getSbh() > 0 ? 1 : 0, feeComponents.getSbh() / HRS_DIVISOR);
    long rbhNetwork = Math.max(rbsNetwork > 0 ? 1 : 0, (rbsNetwork) / HRS_DIVISOR);
    FeeComponents feeMatricesForTxService = FeeComponents.newBuilder().setConstant(FEE_MATRICES_CONST).setRbh(rbh).setSbh(sbh).setTv(feeComponents.getTv()).build();
    FeeComponents feeMatricesForTxNetwork = FeeComponents.newBuilder().setConstant(FEE_MATRICES_CONST).setBpt(feeComponents.getBpt()).setVpt(feeComponents.getVpt()).setRbh(rbhNetwork).build();
    FeeComponents feeMatricesForTxNode = FeeComponents.newBuilder().setConstant(FEE_MATRICES_CONST).setBpt(feeComponents.getBpt()).setVpt(payerVpt).setBpr(feeComponents.getBpr()).setSbpr(feeComponents.getSbpr()).build();
    return FeeData.newBuilder().setNetworkdata(feeMatricesForTxNetwork).setNodedata(feeMatricesForTxNode).setServicedata(feeMatricesForTxService).build();
}
Also used : FeeComponents(com.hederahashgraph.api.proto.java.FeeComponents)

Example 2 with FeeComponents

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

the class FeeBuilder method getQueryFeeDataMatrices.

public static FeeData getQueryFeeDataMatrices(FeeComponents feeComponents) {
    FeeComponents feeMatricesForTxService = FeeComponents.getDefaultInstance();
    FeeComponents feeMatricesForTxNetwork = FeeComponents.getDefaultInstance();
    FeeComponents feeMatricesForTxNode = FeeComponents.newBuilder().setConstant(FEE_MATRICES_CONST).setBpt(feeComponents.getBpt()).setBpr(feeComponents.getBpr()).setSbpr(feeComponents.getSbpr()).build();
    return FeeData.newBuilder().setNetworkdata(feeMatricesForTxNetwork).setNodedata(feeMatricesForTxNode).setServicedata(feeMatricesForTxService).build();
}
Also used : FeeComponents(com.hederahashgraph.api.proto.java.FeeComponents)

Example 3 with FeeComponents

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

the class FileFeeBuilder method getSystemDeleteFileTxFeeMatrices.

public FeeData getSystemDeleteFileTxFeeMatrices(TransactionBody txBody, SigValueObj numSignatures) throws InvalidTxBodyException {
    if (txBody == null || !txBody.hasSystemDelete()) {
        throw new InvalidTxBodyException("System Delete Tx Body not available for Fee Calculation");
    }
    long bpt = 0;
    long vpt = 0;
    long rbs = 0;
    long sbs = 0;
    long gas = 0;
    long tv = 0;
    long bpr = 0;
    long sbpr = 0;
    // get the bytes per second
    bpt = getCommonTransactionBodyBytes(txBody);
    bpt = bpt + BASIC_ENTITY_ID_SIZE + LONG_SIZE;
    vpt = numSignatures.getTotalSigCount();
    rbs = calculateRBS(txBody);
    long rbsNetwork = getDefaultRBHNetworkSize();
    // sbs should not be charged as the fee for storage was already paid. What if expiration is changed though?
    FeeComponents feeMatricesForTx = FeeComponents.newBuilder().setBpt(bpt).setVpt(vpt).setRbh(rbs).setSbh(sbs).setGas(gas).setTv(tv).setBpr(bpr).setSbpr(sbpr).build();
    return getFeeDataMatrices(feeMatricesForTx, numSignatures.getPayerAcctSigCount(), rbsNetwork);
}
Also used : InvalidTxBodyException(com.hederahashgraph.exception.InvalidTxBodyException) FeeComponents(com.hederahashgraph.api.proto.java.FeeComponents)

Example 4 with FeeComponents

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

the class FileFeeBuilder method getFileContentQueryFeeMatrices.

/**
 * This method returns fee matrices for file content query
 *
 * @param contentSize content size
 * @param responseType response type
 *
 * @return fee data
 */
public FeeData getFileContentQueryFeeMatrices(int contentSize, ResponseType responseType) {
    // get the Fee Matrices
    long bpt = 0;
    long vpt = 0;
    long rbs = 0;
    long sbs = 0;
    long gas = 0;
    long tv = 0;
    long bpr = 0;
    long sbpr = 0;
    /*
     * FileGetContentsQuery QueryHeader Transaction - CryptoTransfer - (will be taken care in
     * Transaction processing) ResponseType - INT_SIZE FileID - BASIC_ENTITY_ID_SIZE
     */
    bpt = calculateBPT();
    /*
     *
     * Response header NodeTransactionPrecheckCode - 4 bytes ResponseType - 4 bytes
     *
     * FileContents FileID fileID - BASIC_ENTITY_ID_SIZE bytes content - calculated value (size of the
     * content)
     *
     */
    bpr = BASIC_QUERY_RES_HEADER + getStateProofSize(responseType);
    sbpr = (long) BASIC_ENTITY_ID_SIZE + contentSize;
    FeeComponents feeMatrices = FeeComponents.newBuilder().setBpt(bpt).setVpt(vpt).setRbh(rbs).setSbh(sbs).setGas(gas).setTv(tv).setBpr(bpr).setSbpr(sbpr).build();
    return getQueryFeeDataMatrices(feeMatrices);
}
Also used : FeeComponents(com.hederahashgraph.api.proto.java.FeeComponents)

Example 5 with FeeComponents

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

the class FileFeeBuilder method getFileDeleteTxFeeMatrices.

public FeeData getFileDeleteTxFeeMatrices(TransactionBody txBody, SigValueObj sigValObj) throws InvalidTxBodyException {
    if (txBody == null || !txBody.hasFileDelete()) {
        throw new InvalidTxBodyException("FileDelete Tx Body not available for Fee Calculation");
    }
    long bpt = 0;
    long vpt = 0;
    long rbs = 0;
    long sbs = 0;
    long gas = 0;
    long tv = 0;
    long bpr = 0;
    long sbpr = 0;
    final long txBodySize = getCommonTransactionBodyBytes(txBody);
    // bpt - Bytes per Transaction
    bpt = txBodySize + BASIC_ENTITY_ID_SIZE + sigValObj.getSignatureSize();
    // vpt - verifications per transactions
    vpt = sigValObj.getTotalSigCount();
    bpr = INT_SIZE;
    rbs = calculateRBS(txBody);
    long rbsNetwork = getDefaultRBHNetworkSize();
    FeeComponents feeMatricesForTx = FeeComponents.newBuilder().setBpt(bpt).setVpt(vpt).setRbh(rbs).setSbh(sbs).setGas(gas).setTv(tv).setBpr(bpr).setSbpr(sbpr).build();
    return getFeeDataMatrices(feeMatricesForTx, sigValObj.getPayerAcctSigCount(), rbsNetwork);
}
Also used : InvalidTxBodyException(com.hederahashgraph.exception.InvalidTxBodyException) FeeComponents(com.hederahashgraph.api.proto.java.FeeComponents)

Aggregations

FeeComponents (com.hederahashgraph.api.proto.java.FeeComponents)14 InvalidTxBodyException (com.hederahashgraph.exception.InvalidTxBodyException)7 Test (org.junit.jupiter.api.Test)1