Skip to content

Commit

Permalink
hardcoded mainnet timestamp data for first 10 blocks (#281)
Browse files Browse the repository at this point in the history
  • Loading branch information
PavitraAgarwal21 authored Oct 22, 2024
1 parent c830ced commit a2f8571
Showing 1 changed file with 121 additions and 0 deletions.
121 changes: 121 additions & 0 deletions scripts/data/generate_timestamp_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,132 @@ 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",
"previous_timestamps": [],
},
1: {
"block_number": "1",
"epoch_start_time": "1231469665",
"previous_timestamps": ["1231006505"],
},
2: {
"block_number": "2",
"epoch_start_time": "1231469744",
"previous_timestamps": ["1231006505", "1231469665"],
},
3: {
"block_number": "3",
"epoch_start_time": "1231470173",
"previous_timestamps": ["1231006505", "1231469665", "1231469744"],
},
4: {
"block_number": "4",
"epoch_start_time": "1231470988",
"previous_timestamps": [
"1231006505",
"1231469665",
"1231469744",
"1231470173",
],
},
5: {
"block_number": "5",
"epoch_start_time": "1231471428",
"previous_timestamps": [
"1231006505",
"1231469665",
"1231469744",
"1231470173",
"1231470988",
],
},
6: {
"block_number": "6",
"epoch_start_time": "1231471789",
"previous_timestamps": [
"1231006505",
"1231469665",
"1231469744",
"1231470173",
"1231470988",
"1231471428",
],
},
7: {
"block_number": "7",
"epoch_start_time": "1231472369",
"previous_timestamps": [
"1231006505",
"1231469665",
"1231469744",
"1231470173",
"1231470988",
"1231471428",
"1231471789",
],
},
8: {
"block_number": "8",
"epoch_start_time": "1231472743",
"previous_timestamps": [
"1231006505",
"1231469665",
"1231469744",
"1231470173",
"1231470988",
"1231471428",
"1231471789",
"1231472369",
],
},
9: {
"block_number": "9",
"epoch_start_time": "1231473279",
"previous_timestamps": [
"1231006505",
"1231469665",
"1231469744",
"1231470173",
"1231470988",
"1231471428",
"1231471789",
"1231472369",
"1231472743",
],
},
10: {
"block_number": "10",
"epoch_start_time": "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

0 comments on commit a2f8571

Please sign in to comment.