Skip to content

Commit

Permalink
fix: unnested if else blocks
Browse files Browse the repository at this point in the history
Signed-off-by: Logan Nguyen <[email protected]>
  • Loading branch information
quiet-node committed Sep 9, 2024
1 parent 8af93f2 commit 3a29b5e
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions packages/relay/src/lib/hbarlimiter/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,25 +148,25 @@ export default class HbarLimit {
`${requestIdPrefix} HBAR preemptive rate limit bypassed - the caller is a whitelisted account: originalCallerAddress=${originalCallerAddress}`,
);
return false;
} else {
const { fileCreateTransactions, fileAppendTransactions, transactionFee } = this.estimateFileTransactionFee(
callDataSize,
fileChunkSize,
currentNetworkExchangeRateInCents,
);
}

if (this.remainingBudget - transactionFee < 0) {
this.logger.warn(
`${requestIdPrefix} HBAR preemptive rate limit incoming call - the total preemptive transaction fee exceeds the current remaining HBAR budget due to an excessively large callData size: remainingBudget=${this.remainingBudget}, total=${this.total}, resetTimestamp=${this.reset}, callDataSize=${callDataSize}, fileCreateTransactions=${fileCreateTransactions}, fileAppendTransactions=${fileAppendTransactions}, transactionFee=${transactionFee}, exchangeRateInCents=${currentNetworkExchangeRateInCents}`,
);
return true;
} else {
this.logger.trace(
`${requestIdPrefix} HBAR preemptive rate limit not reached: remainingBudget=${this.remainingBudget}, total=${this.total}, resetTimestamp=${this.reset}, callDataSize=${callDataSize}, fileCreateTransactions=${fileCreateTransactions}, fileAppendTransactions=${fileAppendTransactions}, transactionFee=${transactionFee}, exchangeRateInCents=${currentNetworkExchangeRateInCents}`,
);
return false;
}
const { fileCreateTransactions, fileAppendTransactions, transactionFee } = this.estimateFileTransactionFee(
callDataSize,
fileChunkSize,
currentNetworkExchangeRateInCents,
);

if (this.remainingBudget - transactionFee < 0) {
this.logger.warn(
`${requestIdPrefix} HBAR preemptive rate limit incoming call - the total preemptive transaction fee exceeds the current remaining HBAR budget due to an excessively large callData size: remainingBudget=${this.remainingBudget}, total=${this.total}, resetTimestamp=${this.reset}, callDataSize=${callDataSize}, fileCreateTransactions=${fileCreateTransactions}, fileAppendTransactions=${fileAppendTransactions}, transactionFee=${transactionFee}, exchangeRateInCents=${currentNetworkExchangeRateInCents}`,
);
return true;
}

this.logger.trace(
`${requestIdPrefix} HBAR preemptive rate limit not reached: remainingBudget=${this.remainingBudget}, total=${this.total}, resetTimestamp=${this.reset}, callDataSize=${callDataSize}, fileCreateTransactions=${fileCreateTransactions}, fileAppendTransactions=${fileAppendTransactions}, transactionFee=${transactionFee}, exchangeRateInCents=${currentNetworkExchangeRateInCents}`,
);
return false;
}

/**
Expand Down

0 comments on commit 3a29b5e

Please sign in to comment.