Search in sources :

Example 6 with FeeData

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

the class AutoRenewCalcsTest method toPostPrices.

private Map<SubType, FeeData> toPostPrices(Map<SubType, FeeData> feeDataMap) {
    var changeableMap = new HashMap<>(feeDataMap);
    for (FeeData feeData : feeDataMap.values()) {
        var postPrices = feeData.toBuilder().setServicedata(feeData.getServicedata().toBuilder().setRbh(2 * feeData.getServicedata().getRbh())).build();
        changeableMap.put(postPrices.getSubType(), postPrices);
    }
    return changeableMap;
}
Also used : HashMap(java.util.HashMap) FeeData(com.hederahashgraph.api.proto.java.FeeData)

Example 7 with FeeData

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

the class BasicFcfsUsagePricesTest method getsTransferUsagePricesAtCurrent.

@Test
void getsTransferUsagePricesAtCurrent() {
    // given:
    subject.loadPriceSchedules();
    Timestamp at = Timestamp.newBuilder().setSeconds(currentExpiry - 1).build();
    // when:
    Map<SubType, FeeData> actual = subject.pricesGiven(ContractCall, at);
    // then:
    assertEquals(currentContractCallPrices, actual);
}
Also used : SubType(com.hederahashgraph.api.proto.java.SubType) Timestamp(com.hederahashgraph.api.proto.java.Timestamp) FeeData(com.hederahashgraph.api.proto.java.FeeData) Test(org.junit.jupiter.api.Test)

Example 8 with FeeData

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

the class BasicFcfsUsagePricesTest method getsTransferUsagePricesPastCurrentBeforeNextExpiry.

@Test
void getsTransferUsagePricesPastCurrentBeforeNextExpiry() throws Exception {
    // given:
    subject.loadPriceSchedules();
    Timestamp at = Timestamp.newBuilder().setSeconds(nextExpiry - 1).build();
    // when:
    Map<SubType, FeeData> actual = subject.pricesGiven(ContractCall, at);
    // then:
    assertEquals(nextContractCallPrices, actual);
}
Also used : SubType(com.hederahashgraph.api.proto.java.SubType) Timestamp(com.hederahashgraph.api.proto.java.Timestamp) FeeData(com.hederahashgraph.api.proto.java.FeeData) Test(org.junit.jupiter.api.Test)

Example 9 with FeeData

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

the class ScheduleTypePatching method ensurePatchedFeeScheduleHasRequiredTypes.

private void ensurePatchedFeeScheduleHasRequiredTypes(TransactionFeeSchedule origTfs, TransactionFeeSchedule.Builder patchedTfs, Set<SubType> requiredTypes) {
    /* The deprecated prices are the final fallback; if even they are not set, the function will be free */
    final var oldDefaultPrices = origTfs.getFeeData();
    FeeData explicitDefaultPrices = null;
    /* First determine what types are already present; and what default prices to use, if any */
    final List<SubType> listedTypes = new ArrayList<>();
    for (var typedPrices : origTfs.getFeesList()) {
        final var type = typedPrices.getSubType();
        listedTypes.add(type);
        if (type == DEFAULT) {
            explicitDefaultPrices = typedPrices;
        }
    }
    final Set<SubType> presentTypes = listedTypes.isEmpty() ? EnumSet.noneOf(SubType.class) : EnumSet.copyOf(listedTypes);
    for (var type : requiredTypes) {
        if (!presentTypes.contains(type)) {
            if (explicitDefaultPrices != null) {
                patchedTfs.addFees(explicitDefaultPrices.toBuilder().setSubType(type).build());
            } else {
                patchedTfs.addFees(oldDefaultPrices.toBuilder().setSubType(type).build());
            }
        }
    }
}
Also used : SubType(com.hederahashgraph.api.proto.java.SubType) ArrayList(java.util.ArrayList) FeeData(com.hederahashgraph.api.proto.java.FeeData)

Example 10 with FeeData

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

the class FeeCalculator method forActivityBasedOp.

public long forActivityBasedOp(HederaFunctionality op, ActivityMetrics metricsCalculator, Transaction txn, int numPayerSigs) throws Throwable {
    FeeData activityMetrics = metricsFor(txn, numPayerSigs, metricsCalculator);
    final var subType = activityMetrics.getSubType();
    return forOp(op, subType, activityMetrics);
}
Also used : FeeData(com.hederahashgraph.api.proto.java.FeeData)

Aggregations

FeeData (com.hederahashgraph.api.proto.java.FeeData)10 SubType (com.hederahashgraph.api.proto.java.SubType)4 Test (org.junit.jupiter.api.Test)4 Timestamp (com.hederahashgraph.api.proto.java.Timestamp)3 ArrayList (java.util.ArrayList)2 MockAppender (com.hedera.test.mocks.MockAppender)1 HashMap (java.util.HashMap)1 Level (org.apache.logging.log4j.Level)1