Skip to content

Get random node ids for offline transaction signing. #1222

@Logan-Pageler

Description

@Logan-Pageler

Problem

Transactions must have only one node ID selected for offline signing. However there is no easy way to randomly select one healthy node id.

Ie when people want to do offline signing they will do something like the following for setting the node id:

transfer_transaction.node_account_ids(vec![
    AccountId::from_str("0.0.3").unwrap(),
])

This is especially bad because people can overwhelm one node if they hard code it.

Solution

The sdk already has a private random_node_ids for NetworkData objects that the sdk uses internally for selecting random nodes as the default. This function could be exposed through Client to solve this so people can do the following:

let random_nodes = client.random_node_ids();
random_nodes.truncate(1);
transaction.node_account_ids(random_nodes);

Alternatives

Alternatively a new function could be written for this purpose. Maybe one that takes a number of nodes as an argument to avoid the need to truncate the resulting list.

Additionally implementing #837 could indirectly alleviate this issue as the default random nodes would be fine for offline signing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request
    No fields configured for Feature.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions