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;
}
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);
}
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);
}
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());
}
}
}
}
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);
}
Aggregations