Skip to content

Commit

Permalink
Updated for comments.
Browse files Browse the repository at this point in the history
Signed-off-by: Harsh Sawarkar <[email protected]>
  • Loading branch information
HarshSawarkar committed Feb 21, 2025
1 parent 54d3e09 commit 23dc2bc
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 15 deletions.
16 changes: 7 additions & 9 deletions hedera-mirror-rest/__tests__/specs/schedules/{id}/executed.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,13 @@
"memo": "Created per council decision dated 02/01/21"
}
],
"schedules": [
{
"consensus_timestamp": "1234567890000000001",
"creator_account_id": "0.0.1024",
"payer_account_id": "0.0.1024",
"schedule_id": "0.0.2000",
"executed_timestamp": "1234567895000000000"
}
],
"schedules": {
"consensus_timestamp": "1234567890000000001",
"creator_account_id": "0.0.1024",
"payer_account_id": "0.0.1024",
"schedule_id": "0.0.2000",
"executed_timestamp": "1234567895000000000"
},
"transactionsignatures": [
{
"consensus_timestamp": "1234567890000000001",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@
"responseJson": {
"admin_key": {
"_type": "ProtobufEncoded",
"key": "AQEB"
"key": "010101"
},
"consensus_timestamp": "1234567890.000000001",
"creator_account_id": "0.0.1024",
"deleted": false,
"expiration_time": "1234567890.000000001",
"expiration_time": "1234567890.600000001",
"executed_timestamp": null,
"memo": "Explicitly expired schedule",
"payer_account_id": "0.0.1024",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"responseJson": {
"admin_key": {
"_type": "ProtobufEncoded",
"key": "AQEB"
"key": "010101"
},
"consensus_timestamp": "1234567890.000000001",
"creator_account_id": "0.0.1024",
Expand Down
6 changes: 3 additions & 3 deletions hedera-mirror-rest/schedules.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,10 @@ const getScheduleById = async (req, res) => {
const getScheduleCacheControlHeader = (schedule) => {

Check warning on line 143 in hedera-mirror-rest/schedules.js

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

hedera-mirror-rest/schedules.js#L143

Method getScheduleCacheControlHeader has a cyclomatic complexity of 9 (limit is 8)
const nowNs = BigInt(utils.nowInNs());
const executedTimestamp = schedule.executed_timestamp;
const expirationTime = schedule.expiration_time !== undefined ? BigInt(schedule.expiration_time) : 0n;
const consensusTimestamp = schedule.consensus_timestamp !== undefined ? BigInt(schedule.consensus_timestamp) : 0n;
const expirationTime = schedule.expiration_time ? BigInt(schedule.expiration_time) : 0n;
const consensusTimestamp = schedule.consensus_timestamp ? BigInt(schedule.consensus_timestamp) : 0n;

const hasExecuted = executedTimestamp !== undefined || schedule.deleted;
const hasExecuted = executedTimestamp || schedule.deleted;
const hasAutoExpired =
expirationTime === 0n && nowNs >= consensusTimestamp + constants.THIRTY_ONE_MINUTES * constants.ONE_BILLION;
const hasExpired = expirationTime !== 0n && nowNs >= expirationTime + constants.SIXTY_SECONDS * constants.ONE_BILLION;
Expand Down

0 comments on commit 23dc2bc

Please sign in to comment.