Skip to content

Commit df7a63a

Browse files
committed
feat: support selecting node account ID for execution flow
Signed-off-by: Angelina <[email protected]>
1 parent 82bfd6b commit df7a63a

File tree

4 files changed

+14
-7
lines changed

4 files changed

+14
-7
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ This changelog is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.
2323
### Fixed
2424

2525
- Added explicit read permissions to examples.yml (#623)
26+
- Added node_account_ids selection method support (#362)
2627
- Improved type hinting in `file_append_transaction.py` to resolve 'mypy --strict` errors. ([#495](https://github.com/hiero-ledger/hiero-sdk-python/issues/495))
2728

2829
### Breaking Changes

src/hiero_sdk_python/executable.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -176,10 +176,15 @@ def _execute(self, client: "Client"):
176176
if attempt > 0 and current_backoff < self._max_backoff:
177177
current_backoff *= 2
178178

179-
# Set the node account id to the client's node account id
180-
node = client.network.current_node
181-
self.node_account_id = node._account_id
182-
179+
# Select preferred node if provided, fallback to client's default
180+
selected_node_account_id = (
181+
self._select_node_account_id()
182+
or client.network.current_node._account_id
183+
)
184+
185+
self.node_account_id = selected_node_account_id
186+
node = client.network._get_node(self.node_account_id)
187+
183188
# Create a channel wrapper from the client's channel
184189
channel = node._get_channel()
185190

src/hiero_sdk_python/query/query.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,4 +421,5 @@ def _select_node_account_id(self) -> Optional[AccountId]:
421421
selected = self.node_account_ids[0]
422422
self._used_node_account_id = selected
423423
return selected
424-
return None
424+
return None
425+

src/hiero_sdk_python/transaction/transaction.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ def set_node_account_ids(self, node_account_ids: List[AccountId]):
502502

503503
def set_node_account_id(self, node_account_id: AccountId):
504504
"""
505-
Selects a node account ID to use for sending a query.
505+
Selects a node account ID to use for sending a transaction.
506506
507507
Args:
508508
node_account_id (AccountId): The node account ID.
@@ -515,7 +515,7 @@ def set_node_account_id(self, node_account_id: AccountId):
515515

516516
def _select_node_account_id(self) -> Optional[AccountId]:
517517
"""
518-
Selects a node account ID to use for sending a query.
518+
Selects a node account ID to use for sending a transaction.
519519
520520
Picks the first unused node from `self.node_account_ids`.
521521
Once used, stores it in `_used_node_account_id`.

0 commit comments

Comments
 (0)