Last active
August 1, 2022 06:09
-
-
Save jack60612/ebe540d47e9c4a360f6af45f062f403b to your computer and use it in GitHub Desktop.
Enter a ph to check if it had CAT1's at EOL Height
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import csv | |
target_csv = "cat1_csv_files/000_cat1-snapshot.csv" | |
all_addresses_file_name = "all_cat1_addresses.txt" | |
def main(): | |
print(f"Loading {target_csv}, this might take a while.") | |
with open(target_csv, mode='r') as csv_file: | |
csv_reader = csv.DictReader(csv_file, fieldnames=["tail_id", "target_ph", "amount"]) | |
print(f"Loading complete!") | |
target_ph_str = input("Enter target_ph, print all puzzle_hashes to a file by entering a, or press q to quit: ") | |
while target_ph_str != "q" and target_ph_str != "": | |
if target_ph_str == "a": | |
parse_csv_to_all_puzzles(csv_reader) | |
break | |
else: | |
parse_csv_dict(csv_reader, target_ph_str) | |
target_ph_str = input("Enter target_ph, or press q to quit: ").lower() | |
def parse_csv_dict(csv_dict: csv.DictReader, target_ph_str: str): | |
line_count = 0 | |
for row in csv_dict: | |
if line_count == 0: | |
print(f'Column names are {", ".join(row)}') | |
line_count += 1 | |
if target_ph_str in row["target_ph"]: | |
print(f"Matching row: Tail ID: 0x{row['tail_id']}, Puzzle Hash as of EOL Height: 0x{row['target_ph']}, Amount: {int(row['amount'])/ 10 ** 3} CAT") | |
line_count += 1 | |
print(f'Processed {line_count} lines.') | |
def parse_csv_to_all_puzzles(csv_dict: csv.DictReader): | |
line_count = 0 | |
all_puzzle_hashes = set() | |
for row in csv_dict: | |
if line_count == 0: | |
print(f'Column names are {", ".join(row)}') | |
line_count += 1 | |
all_puzzle_hashes.add("0x" + row["target_ph"]) | |
line_count += 1 | |
print(f'Processed {line_count} lines. With a total of: {len(all_puzzle_hashes)} unique puzzle-hashes.') | |
textfile = open(all_addresses_file_name, "w") | |
for puzzle_hash in all_puzzle_hashes: | |
textfile.write(puzzle_hash + "\n") | |
textfile.close() | |
print(f"All Puzzle Hashes added to {all_addresses_file_name}, Quitting.") | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment