use of com.hedera.services.usage.crypto.CryptoUpdateMeta in project hedera-services by hashgraph.
the class HapiCryptoUpdate method feeFor.
@Override
protected long feeFor(HapiApiSpec spec, Transaction txn, int numPayerKeys) throws Throwable {
try {
final CryptoGetInfoResponse.AccountInfo info = lookupInfo(spec);
FeeCalculator.ActivityMetrics metricsCalc = (_txn, svo) -> {
var ctx = ExtantCryptoContext.newBuilder().setCurrentNumTokenRels(info.getTokenRelationshipsCount()).setCurrentExpiry(info.getExpirationTime().getSeconds()).setCurrentMemo(info.getMemo()).setCurrentKey(info.getKey()).setCurrentlyHasProxy(info.hasProxyAccountID()).setCurrentMaxAutomaticAssociations(info.getMaxAutomaticTokenAssociations()).build();
var baseMeta = new BaseTransactionMeta(_txn.getMemoBytes().size(), 0);
var opMeta = new CryptoUpdateMeta(_txn.getCryptoUpdateAccount(), _txn.getTransactionID().getTransactionValidStart().getSeconds());
var accumulator = new UsageAccumulator();
cryptoOpsUsage.cryptoUpdateUsage(suFrom(svo), baseMeta, opMeta, ctx, accumulator);
return AdapterUtils.feeDataFrom(accumulator);
};
return spec.fees().forActivityBasedOp(HederaFunctionality.CryptoUpdate, metricsCalc, txn, numPayerKeys);
} catch (Throwable ignore) {
return HapiApiSuite.ONE_HBAR;
}
}
Aggregations