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

Develop #5

Merged
merged 6 commits into from
Mar 8, 2024
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
1 change: 1 addition & 0 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ def update_charts(wallet_address):
color='networkDifficulty',
labels={'Time Found': 'Block Creation Date',
'effort': 'Effort', 'networkDifficulty': 'Network Difficulty'})


# # adding a circle to the effort chart if you found the block
# try:
Expand Down
2 changes: 1 addition & 1 deletion conf/conf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ user_defined:
default_values:
url: 'https://api.ergo.aap.cornell.edu/api/v1/boxes/unspent/byAddress/'
token_ls: 'https://api.ergo.aap.cornell.edu/api/v1/tokens'
base_api: 'http://74.69.128.24:4000/api/pools/ErgoSigmanauts'
base_api: 'http://15.204.211.130:4000/api/pools/ErgoSigmanauts'
Binary file added utils/__pycache__/dash_utils.cpython-39.pyc
Binary file not shown.
Binary file added utils/__pycache__/reader.cpython-39.pyc
Binary file not shown.
29 changes: 23 additions & 6 deletions utils/reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,10 @@ def get_block_stats(self, wallet):
except KeyError:
miners[miner] = 1
blocks[block_height] = block['effort']

average_effort = {'Average Block Effort': sum(blocks.values()) / len(blocks)}
try:
average_effort = {'Average Block Effort': sum(blocks.values()) / len(blocks)}
except ZeroDivisionError:
average_effort = {'Average Block Effort': 0}

block_df = DataFrame(block_data)

Expand All @@ -143,6 +145,10 @@ def get_block_stats(self, wallet):
print('my wallet_value errr')
block_df['my_wallet'] = 'NOT ENTERED'
miner_df['my_wallet'] = 'NOT ENTERED'

except KeyError:
block_df['my_wallet'] = 'NONE'
miner_df['my_wallet'] = 'NONE'

miner_df['miner'] = miner_df['miner'].apply(lambda x: f"{x[:5]}...{x[-5:]}" if len(x) > 10 else x)

Expand All @@ -151,13 +157,24 @@ def get_block_stats(self, wallet):
effort_df.reset_index(inplace=True)
effort_df.columns = ['Mining Stats', 'Values']

try:
block_df['Time Found'] = to_datetime(block_df['created'])
block_df['Time Found'] = block_df['Time Found'].dt.strftime('%Y-%m-%d %H:%M:%S')
except KeyError:
block_df['Time Found'] = 'Not Found Yet'

try:
block_df['miner'] = block_df['miner'].apply(lambda x: f"{x[:5]}...{x[-5:]}" if len(x) > 10 else x)
block_df['effort'] = round(block_df['effort'], 5)
except KeyError:
block_df['miner'] = 'NONE'
block_df['effort'] = 'NONE'
block_df['networkDifficulty'] = 0

block_df['Time Found'] = to_datetime(block_df['created'])
block_df['Time Found'] = block_df['Time Found'].dt.strftime('%Y-%m-%d %H:%M:%S')
block_df['miner'] = block_df['miner'].apply(lambda x: f"{x[:5]}...{x[-5:]}" if len(x) > 10 else x)
block_df['effort'] = round(block_df['effort'], 5)

block_df = block_df.filter(['Time Found', 'blockHeight', 'effort', 'status', 'confirmationProgress', 'reward',
'miner', 'networkDifficulty', 'my_wallet'])


return block_df, miner_df, effort_df

Expand Down
Loading