Class Pool
Represents a connection to a pool of ledger nodes and provides static methods for managing connections to pools.
Inheritance
Implements
Namespace: Hyperledger.Indy.PoolApi
Assembly: Hyperledger.Indy.Sdk.dll
Syntax
public sealed class Pool : Object, IDisposable
Methods
CloseAsync()
Closes the pool.
Declaration
public Task CloseAsync()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | An asynchronous System.Threading.Tasks.Task that completes when the operation completes. |
Remarks
note
Once a Pool instance is closed it cannot be opened again. Instead call the OpenPoolLedgerAsync(String, String) method to open a new Pool instance.
CreatePoolLedgerConfigAsync(String, String)
Creates a new local pool configuration with the specified name that can be used later to open a connection to pool nodes.
Declaration
public static Task CreatePoolLedgerConfigAsync(string configName, string config)
Parameters
Type | Name | Description |
---|---|---|
System.String | configName | The name for the configuration. |
System.String | config | The configuration JSON. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | An asynchronous System.Threading.Tasks.Task<> with no return value that completes when the configuration is created. |
Remarks
If the configuration specified in the config
parameter is null then the
default configuration will be used, however if specified the value should adhere to the following
JSON format:
{
"genesis_txn": "path/to/genesis/transaction/file"
}
If the value of the genesis_txn
key in the JSON is null then a default file will be
used. If the file specified does not exist it will be created.
See Also
DeletePoolLedgerConfigAsync(String)
Deletes an existing pool configuration.
Declaration
public static Task DeletePoolLedgerConfigAsync(string configName)
Parameters
Type | Name | Description |
---|---|---|
System.String | configName | The name of the configuration to delete. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | An asynchronous System.Threading.Tasks.Task<> with no return value that completes when the configuration is deleted. |
See Also
Dispose()
Disposes of resources.
Declaration
public void Dispose()
Finalize()
Finalizes the resource during GC if it hasn't been already.
Declaration
protected override void Finalize()
ListPoolsAsync()
Declaration
public static Task<string> ListPoolsAsync()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.String> |
OpenPoolLedgerAsync(String, String)
Opens a pool and connects to the ledger nodes.
Declaration
public static Task<Pool> OpenPoolLedgerAsync(string configName, string config)
Parameters
Type | Name | Description |
---|---|---|
System.String | configName | The name of the pool configuration to use. |
System.String | config | The runtime configuration to use. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<Pool> | An asynchronous System.Threading.Tasks.Task<> that resolves to a Pool instance once the pool is opened. |
Remarks
A Pool cannot be opened unless the a pool configuration with the specified name was previously configured using the CreatePoolLedgerConfigAsync(String, String) method.
When opening a pool the runtime configuration can be specified using the config
parameter, which expects a JSON string with the following format:
{
"refresh_on_open": bool (optional), Forces pool ledger to be refreshed immediately after opening.
Defaults to true.
"auto_refresh_time": int (optional), After this time in minutes pool ledger will be automatically refreshed.
Use 0 to disable automatic refresh. Defaults to 24*60.
"network_timeout": int (optional), Network timeout for communication with nodes in milliseconds.
Defaults to 20000.
}
If the config
parameter is null then the default configuration will be used.
note
Attempting to open a pool with the same name more than once will result in an error.
RefreshAsync()
Refreshes a local copy of the pool and updates the pool's node connections.
Declaration
public Task RefreshAsync()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | An asynchronous System.Threading.Tasks.Task that completes when the operation completes. |
SetProtocolVersionAsync(Int32)
Declaration
public static Task SetProtocolVersionAsync(int protocolVersion)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | protocolVersion |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |