Skip to content

Commit ab18528

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

File tree

4 files changed

+16
-10
lines changed

4 files changed

+16
-10
lines changed

CHANGELOG.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ This changelog is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.
99
### Added
1010

1111
- Add Google-style docstrings to `AccountInfo` class and its methods in `account_info.py`.
12-
13-
- add AccountRecordsQuery class
12+
- Add AccountRecordsQuery class
13+
- Support selecting node account ID(s) for individual queries and transactions (#362)
1414

1515
### Changed
1616

@@ -20,7 +20,7 @@ This changelog is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.
2020
### Fixed
2121

2222
- Added explicit read permissions to examples.yml (#623)
23-
- fix: spacing after set_node_account_id method (#362)
23+
- Added node_account_ids selection method support (#362)
2424

2525
### Breaking Changes
2626

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)