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
7 changes: 5 additions & 2 deletions bittensor/core/async_subtensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ async def determine_block_hash(
# Return the appropriate value.
if block_hash:
return block_hash
if block:
if block is not None:
return await self.get_block_hash(block)
return None

Expand Down Expand Up @@ -1235,6 +1235,9 @@ async def get_balances(
"""
if reuse_block:
block_hash = self.substrate.last_block_hash
elif block_hash is None and block is None:
# Neither block nor block_hash provided, default to head
block_hash = await self.get_block_hash()
else:
block_hash = await self.determine_block_hash(block, block_hash, reuse_block)
calls = [
Expand Down Expand Up @@ -1306,7 +1309,7 @@ async def get_block_hash(self, block: Optional[int] = None) -> str:
Notes:
See also: <https://docs.learnbittensor.org/glossary#block>
"""
if block:
if block is not None:
return await self._get_block_hash(block)
else:
return await self.substrate.get_chain_head()
Expand Down
2 changes: 1 addition & 1 deletion bittensor/core/subtensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -746,7 +746,7 @@ def get_block_hash(self, block: Optional[int] = None) -> str:
data. It is crucial for verifying transactions, ensuring data consistency, and maintaining the
trustworthiness of the blockchain.
"""
if block:
if block is not None:
return self._get_block_hash(block)
else:
return self.substrate.get_chain_head()
Expand Down
12 changes: 6 additions & 6 deletions bittensor/utils/mock/subtensor_mock.py
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ def query_subtensor(
) -> MockSubtensorValue:
if params is None:
params = []
if block:
if block is not None:
if self.block_number < block:
raise Exception("Cannot query block in the future")

Expand Down Expand Up @@ -622,7 +622,7 @@ def query_map_subtensor(
"""
if params is None:
params = []
if block:
if block is not None:
if self.block_number < block:
raise Exception("Cannot query block in the future")

Expand Down Expand Up @@ -668,7 +668,7 @@ def query_map_subtensor(
def query_constant(
self, module_name: str, constant_name: str, block: Optional[int] = None
) -> Optional[object]:
if block:
if block is not None:
if self.block_number < block:
raise Exception("Cannot query block in the future")

Expand Down Expand Up @@ -697,7 +697,7 @@ def get_current_block(self) -> int:
# ==== Balance RPC methods ====

def get_balance(self, address: str, block: int = None) -> "Balance":
if block:
if block is not None:
if self.block_number < block:
raise Exception("Cannot query block in the future")

Expand Down Expand Up @@ -732,7 +732,7 @@ def neuron_for_uid(
if uid is None:
return NeuronInfo.get_null_neuron()

if block:
if block is not None:
if self.block_number < block:
raise Exception("Cannot query block in the future")

Expand Down Expand Up @@ -958,7 +958,7 @@ def neuron_for_uid_lite(
if uid is None:
return NeuronInfoLite.get_null_neuron()

if block:
if block is not None:
if self.block_number < block:
raise Exception("Cannot query block in the future")

Expand Down
Loading