Skip to content
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
76 changes: 38 additions & 38 deletions bittensor/commands/overview.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 +160,15 @@ def run(cli: "bittensor.cli"):
total_coldkey_stake_from_metagraph = defaultdict(
lambda: bittensor.Balance(0.0)
)
checked_hotkeys = set()
for neuron_list in neurons.values():
for neuron in neuron_list:
if neuron.hotkey in checked_hotkeys:
continue
total_coldkey_stake_from_metagraph[
neuron.coldkey
] += neuron.stake_dict[neuron.coldkey]
checked_hotkeys.add(neuron.hotkey)

alerts_table = Table(show_header=True, header_style="bold magenta")
alerts_table.add_column("🥩 alert!")
Expand Down Expand Up @@ -209,40 +213,38 @@ def run(cli: "bittensor.cli"):
)
executor.shutdown(wait=True) # wait for all complete

for result in results:
coldkey_wallet, de_registered_stake, err_msg = result
if err_msg is not None:
console.print(err_msg)
for result in results:
coldkey_wallet, de_registered_stake, err_msg = result
if err_msg is not None:
console.print(err_msg)

if len(de_registered_stake) == 0:
continue # We have no de-registered stake with this coldkey.

de_registered_neurons = []
for hotkey_addr, our_stake in de_registered_stake:
# Make a neuron info lite for this hotkey and coldkey.
de_registered_neuron = bittensor.NeuronInfoLite._null_neuron()
de_registered_neuron.hotkey = hotkey_addr
de_registered_neuron.coldkey = (
coldkey_wallet.coldkeypub.ss58_address
)
de_registered_neuron.total_stake = bittensor.Balance(our_stake)

de_registered_neurons.append(de_registered_neuron)

# Add this hotkey to the wallets dict
wallet_ = bittensor.Wallet(
name=wallet,
)
wallet_.hotkey = hotkey_addr
wallet.hotkey_str = hotkey_addr[:5] # Max length of 5 characters
hotkey_coldkey_to_hotkey_wallet[hotkey_addr][
coldkey_wallet.coldkeypub.ss58_address
] = wallet_

if len(de_registered_stake) == 0:
continue # We have no de-registered stake with this coldkey.

de_registered_neurons = []
for hotkey_addr, our_stake in de_registered_stake:
# Make a neuron info lite for this hotkey and coldkey.
de_registered_neuron = bittensor.NeuronInfoLite._null_neuron()
de_registered_neuron.hotkey = hotkey_addr
de_registered_neuron.coldkey = (
coldkey_wallet.coldkeypub.ss58_address
)
de_registered_neuron.total_stake = bittensor.Balance(our_stake)

de_registered_neurons.append(de_registered_neuron)

# Add this hotkey to the wallets dict
wallet_ = bittensor.Wallet(
name=wallet,
)
wallet_.hotkey = hotkey_addr
wallet.hotkey_str = hotkey_addr[
:5
] # Max length of 5 characters
hotkey_coldkey_to_hotkey_wallet[hotkey_addr][
coldkey_wallet.coldkeypub.ss58_address
] = wallet_

# Add neurons to overview.
neurons["-1"].extend(de_registered_neurons)
# Add neurons to overview.
neurons["-1"].extend(de_registered_neurons)

# Setup outer table.
grid = Table.grid(pad_edge=False)
Expand Down Expand Up @@ -551,13 +553,11 @@ def _get_de_registered_stake_for_coldkey_wallet(
## Filter out hotkeys that are in our wallets
## Filter out hotkeys that are delegates.
def _filter_stake_info(stake_info: "bittensor.StakeInfo") -> bool:
hotkey_addr, our_stake = stake_info

if our_stake == 0:
if stake_info.stake == 0:
return False # Skip hotkeys that we have no stake with.
if hotkey_addr in all_hotkey_addresses:
if stake_info.hotkey_ss58 in all_hotkey_addresses:
return False # Skip hotkeys that are in our wallets.
if subtensor.is_hotkey_delegate(hotkey_ss58=hotkey_addr):
if subtensor.is_hotkey_delegate(hotkey_ss58=stake_info.hotkey_ss58):
return False # Skip hotkeys that are delegates, they show up in btcli my_delegates table.

return True
Expand Down
1 change: 1 addition & 0 deletions bittensor/utils/formatting.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import math


def get_human_readable(num, suffix="H"):
for unit in ["", "K", "M", "G", "T", "P", "E", "Z"]:
if abs(num) < 1000.0:
Expand Down