Skip to content

Commit 35c32da

Browse files
committed
Adds archive node logic
1 parent f03f2af commit 35c32da

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

bittensor_cli/src/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ class Constants:
3333
"latent-lite": latent_lite_entrypoint,
3434
"subvortex": subvortex_entrypoint,
3535
}
36+
genesis_block_hash_map = {
37+
"finney": "0x2f0555cc76fc2840a25a6ea3b9637146806f1f44b090c175ffde2a7e5ab36c03",
38+
"test": "0x8f9cf856bf558a14440e75569c9e58594757048d7b3a84b5d25f6bd978263105",
39+
}
3640
delegates_detail_url = "https://raw.githubusercontent.com/opentensor/bittensor-delegates/main/public/delegates.json"
3741

3842

bittensor_cli/src/commands/wallets.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from rich.padding import Padding
1717
from rich.prompt import Confirm
1818

19-
from bittensor_cli.src import COLOR_PALETTE, COLORS
19+
from bittensor_cli.src import COLOR_PALETTE, COLORS, Constants
2020
from bittensor_cli.src.bittensor import utils
2121
from bittensor_cli.src.bittensor.balances import Balance
2222
from bittensor_cli.src.bittensor.chain_data import (
@@ -1594,6 +1594,19 @@ async def find_coldkey_swap_extrinsic(
15941594
- execution_block: Block number when swap will execute
15951595
Empty dict if not found
15961596
"""
1597+
1598+
current_block, genesis_block = await asyncio.gather(
1599+
subtensor.substrate.get_block_number(),
1600+
subtensor.substrate.get_block_hash(0)
1601+
)
1602+
if (
1603+
current_block - start_block > 300
1604+
and genesis_block == Constants.genesis_block_hash_map["finney"]
1605+
):
1606+
console.print("Querying archive node for coldkey swap events...")
1607+
await subtensor.substrate.close()
1608+
subtensor = SubtensorInterface("archive")
1609+
15971610
block_hashes = await asyncio.gather(
15981611
*[
15991612
subtensor.substrate.get_block_hash(block_num)

0 commit comments

Comments
 (0)