Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add timezone info to all objects. #1017

Merged
merged 1 commit into from
May 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions aquarius/events/decryptor.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
import json
import logging
from datetime import datetime
from datetime import datetime, timezone
from hashlib import sha256

import requests
Expand All @@ -17,7 +17,7 @@

def decrypt_ddo(w3, provider_url, contract_address, chain_id, txid, hash, es_instance):
aquarius_account = get_aquarius_wallet()
nonce = str(int(datetime.utcnow().timestamp()))
nonce = str(int(datetime.now(timezone.utc).timestamp()))

signature = get_signature_bytes(
f"{txid}{aquarius_account.address}{chain_id}{nonce}"
Expand Down
14 changes: 8 additions & 6 deletions aquarius/retry_mechanism.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Copyright 2023 Ocean Protocol Foundation
# SPDX-License-Identifier: Apache-2.0
#
from datetime import datetime, timedelta
from datetime import datetime, timedelta, timezone
import elasticsearch
from hashlib import sha256
from hexbytes import HexBytes
Expand Down Expand Up @@ -88,7 +88,9 @@ def get_from_retry_queue(self):
"must": [
{
"range": {
"next_retry": {"lt": int(datetime.utcnow().timestamp())}
"next_retry": {
"lt": int(datetime.now(timezone.utc).timestamp())
}
}
},
{"term": {"chain_id": self._chain_id}},
Expand Down Expand Up @@ -140,7 +142,7 @@ def add_block_to_retry_queue(self, block_number):
"number_retries": 0,
"next_retry": 0,
"data": {"block": str(block_number)},
"create_timestamp": int(datetime.utcnow().timestamp()),
"create_timestamp": int(datetime.now(timezone.utc).timestamp()),
}
id = self.create_id(element)
element["id"] = id
Expand All @@ -159,7 +161,7 @@ def add_tx_to_retry_queue(self, tx_id, log_index=None):
"number_retries": 0,
"next_retry": 0,
"data": {"txId": str(tx_id)},
"create_timestamp": int(datetime.utcnow().timestamp()),
"create_timestamp": int(datetime.now(timezone.utc).timestamp()),
}
if log_index:
element["data"]["log_index"] = log_index
Expand All @@ -185,7 +187,7 @@ def add_event_to_retry_queue(self, event, nft_address: None, error: None):
"next_retry": 0,
"data": {"txt": Web3.to_json(event)},
"error": error,
"create_timestamp": int(datetime.utcnow().timestamp()),
"create_timestamp": int(datetime.now(timezone.utc).timestamp()),
}
id = self.create_id(element)
element["id"] = id
Expand All @@ -210,7 +212,7 @@ def add_element_to_retry_queue(self, element):

element["next_retry"] = int(
(
datetime.utcnow()
datetime.now(timezone.utc)
+ (element["number_retries"] + 1) * self.retry_interval
).timestamp()
)
Expand Down