Class ConsensusNodeDataExtensions
Extension methods for querying consensus node data from the mirror node.
Inherited Members
Namespace: Hiero.Mirror
Assembly: Hiero.dll
Syntax
public static class ConsensusNodeDataExtensions
Methods
| Edit this page View SourceGetActiveConsensusNodesAsync(MirrorRestClient, int, ConsensusNodeTransport, CancellationToken)
Client-side wrapper over GetConsensusNodesAsync(MirrorRestClient, CancellationToken, params IMirrorQueryParameter[])
that pings the gRPC endpoints returned from
/api/v1/network/nodes and returns only the endpoints that
respond within maxTimeoutInMilliseconds.
Only endpoints that carry an IPv4 address and use port 50211
(plaintext) or 50212 (TLS) are probed; endpoints published with
only a domain name or on another port (as some local networks
do) are skipped. Results are keyed per endpoint, so a node can
appear more than once.
Useful for building a dynamic gateway list for
ConsensusClient transaction submission.
Declaration
public static Task<IReadOnlyDictionary<ConsensusNodeEndpoint, long>> GetActiveConsensusNodesAsync(this MirrorRestClient client, int maxTimeoutInMilliseconds, ConsensusNodeTransport transport = ConsensusNodeTransport.Plaintext, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| MirrorRestClient | client | Mirror Rest Client to use for the request. |
| int | maxTimeoutInMilliseconds | The time value threshold, that if exceeded, will result in the node not being considered active and included on this list. |
| ConsensusNodeTransport | transport | Which transport(s) to return endpoints for. Defaults to Plaintext (unencrypted port 50211) to preserve historical behavior. Tls returns encrypted (port 50212) endpoints, each carrying the node's certificate hash so the client's default channel factory can pin the TLS connection; a node with no usable certificate hash is excluded from the TLS results. All probes and returns both. |
| CancellationToken | cancellationToken | Optional token that cancels the node listing and every ping. A cancelled call throws rather than returning the nodes probed so far. |
Returns
| Type | Description |
|---|---|
| Task<IReadOnlyDictionary<ConsensusNodeEndpoint, long>> | A dictionary of gateways and the corresponding response time (in milliseconds). |
GetConsensusNodesAsync(MirrorRestClient, params IMirrorQueryParameter[])
Enumerates the consensus (gossip) nodes published by the
network's address book, reading from
/api/v1/network/nodes. Use FileFilter to
narrow to a specific address-book file (0.0.101 or
0.0.102) or NodeFilter to narrow by node id.
Declaration
public static IAsyncEnumerable<ConsensusNodeData> GetConsensusNodesAsync(this MirrorRestClient client, params IMirrorQueryParameter[] filters)
Parameters
| Type | Name | Description |
|---|---|---|
| MirrorRestClient | client | Mirror Rest Client to use for the request. |
| IMirrorQueryParameter[] | filters | Additional query parameters. The endpoint supports FileFilter, NodeFilter, PageLimit, and OrderBy. |
Returns
| Type | Description |
|---|---|
| IAsyncEnumerable<ConsensusNodeData> | An async enumerable of consensus-node records. |
GetConsensusNodesAsync(MirrorRestClient, CancellationToken, params IMirrorQueryParameter[])
Enumerates the consensus (gossip) nodes published by the
network's address book, reading from
/api/v1/network/nodes. Use FileFilter to
narrow to a specific address-book file (0.0.101 or
0.0.102) or NodeFilter to narrow by node id.
Declaration
public static IAsyncEnumerable<ConsensusNodeData> GetConsensusNodesAsync(this MirrorRestClient client, CancellationToken cancellationToken, params IMirrorQueryParameter[] filters)
Parameters
| Type | Name | Description |
|---|---|---|
| MirrorRestClient | client | Mirror Rest Client to use for the request. |
| CancellationToken | cancellationToken | Token that cancels the enumeration, including a page request in
flight. |
| IMirrorQueryParameter[] | filters | Additional query parameters. The endpoint supports FileFilter, NodeFilter, PageLimit, and OrderBy. |
Returns
| Type | Description |
|---|---|
| IAsyncEnumerable<ConsensusNodeData> | An async enumerable of consensus-node records. |