hedera-json-rpc-relay icon indicating copy to clipboard operation
hedera-json-rpc-relay copied to clipboard

feat: replaced HbarLimit module with the new HbarLimitService class

Open quiet-node opened this issue 1 year ago • 4 comments
trafficstars

Description:

  • This PR replaces all usages of the HbarLimit module with the new HbarLimitService class in the SdkClient and MetricService classes.
  • Removes the HbarLimit module from the codebase.
  • The addExpense logic in the new HbarLimitService has been updated to accept a nullable ethAddress value. Certain queries, such as getAccountInfo, getBalanceInfo, FileContentsQuery, etc., also add expenses to remainingBalance but don’t always require an originalCaller (ethAddress). Therefore, addExpense can now handle a nullable ethAddress value. If either ethAddress or ipAddress is valid, the spendingPlan logic is applied. Otherwise, it is skipped entirely.
  • Moved the preemptive rate limit logic to the sdkClient.createFile() method.
  • Related tests have been updated to align with the new HbarLimitService class.
  • Updated log messages accordingly.

Related issue(s):

Fixes #2896

Notes for reviewer:

Checklist

  • [x] Documented (Code comments, README, etc.)
  • [x] Tested (unit, integration, etc.)

quiet-node avatar Sep 21 '24 00:09 quiet-node