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

hardcoded mainnet timestamp data for first 10 blocks #281

Merged
merged 3 commits into from
Oct 22, 2024
Merged
Changes from 1 commit
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
132 changes: 132 additions & 0 deletions scripts/data/generate_timestamp_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,143 @@ def load_index(file_name):

def get_timestamp_data(block_number):
"""Get the timestamp data for a given block number."""
if block_number <= 10:
return hardcoded_timestamp_data(block_number)
file_name = index_file_name(int(block_number) // INDEX_SIZE)
index = load_index(file_name)
return index


def hardcoded_timestamp_data(block_number):
def hardcoded_timestamp_data(block_number):
hardcoded_data = {
0: {
"block_number": "0",
"epoch_start_time": "1231006505",
"median_timestamp": "1231006505",
PavitraAgarwal21 marked this conversation as resolved.
Show resolved Hide resolved
"previous_timestamps": [],
},
1: {
"block_number": "1",
"epoch_start_time": "1231469665",
"median_timestamp": "1231469665",
"previous_timestamps": ["1231006505"],
},
2: {
"block_number": "2",
"epoch_start_time": "1231469744",
"median_timestamp": "1231469744",
"previous_timestamps": ["1231006505", "1231469665"],
},
3: {
"block_number": "3",
"epoch_start_time": "1231470173",
"median_timestamp": "1231470173",
"previous_timestamps": ["1231006505", "1231469665", "1231469744"],
},
4: {
"block_number": "4",
"epoch_start_time": "1231470988",
"median_timestamp": "1231470988",
"previous_timestamps": [
"1231006505",
"1231469665",
"1231469744",
"1231470173",
],
},
5: {
"block_number": "5",
"epoch_start_time": "1231471428",
"median_timestamp": "1231471428",
"previous_timestamps": [
"1231006505",
"1231469665",
"1231469744",
"1231470173",
"1231470988",
],
},
6: {
"block_number": "6",
"epoch_start_time": "1231471789",
"median_timestamp": "1231471789",
"previous_timestamps": [
"1231006505",
"1231469665",
"1231469744",
"1231470173",
"1231470988",
"1231471428",
],
},
7: {
"block_number": "7",
"epoch_start_time": "1231472369",
"median_timestamp": "1231472369",
"previous_timestamps": [
"1231006505",
"1231469665",
"1231469744",
"1231470173",
"1231470988",
"1231471428",
"1231471789",
],
},
8: {
"block_number": "8",
"epoch_start_time": "1231472743",
"median_timestamp": "1231472743",
"previous_timestamps": [
"1231006505",
"1231469665",
"1231469744",
"1231470173",
"1231470988",
"1231471428",
"1231471789",
"1231472369",
],
},
9: {
"block_number": "9",
"epoch_start_time": "1231473279",
"median_timestamp": "1231473279",
"previous_timestamps": [
"1231006505",
"1231469665",
"1231469744",
"1231470173",
"1231470988",
"1231471428",
"1231471789",
"1231472369",
"1231472743",
],
},
10: {
"block_number": "10",
"epoch_start_time": "1231473952",
"median_timestamp": "1231473952",
"previous_timestamps": [
"1231006505",
"1231469665",
"1231469744",
"1231470173",
"1231470988",
"1231471428",
"1231471789",
"1231472369",
"1231472743",
"1231473279",
],
},
}

return hardcoded_data.get(block_number, {})


if __name__ == "__main__":
file_names = list_files_in_gcs()
for file_name in tqdm(file_names, "Downloading files"):
Expand Down
Loading