Example #1
0
        /// <summary>
        /// Opens a pool.
        /// </summary>
        /// <param name="configName">The name of the pool configuration to use.</param>
        /// <param name="config">The runtime configuration to use.</param>
        /// <returns>An aysnchronous Task that returns a Pool instance.</returns>
        public static Task <Pool> OpenPoolLedgerAsync(string configName, string config)
        {
            var taskCompletionSource = new TaskCompletionSource <Pool>();
            var commandHandle        = AddTaskCompletionSource(taskCompletionSource);

            var result = IndyNativeMethods.indy_open_pool_ledger(
                commandHandle,
                configName,
                config,
                _openPoolLedgerCallback
                );

            CheckResult(result);

            return(taskCompletionSource.Task);
        }
Example #2
0
        /// <summary>
        /// Opens a pool and connects to the ledger nodes.
        /// </summary>
        /// <remarks>
        /// A Pool cannot be opened unless the a pool configuration with the specified name was previously
        /// configured using the <see cref="CreatePoolLedgerConfigAsync(string, string)"/> method.
        ///
        /// When opening a pool the runtime configuration can be specified using the <paramref name="config"/>
        /// parameter, which expects a JSON string with the following format:
        ///
        /// <code>
        /// {
        ///     "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.
        /// }
        /// </code>
        ///
        /// If the <paramref name="config"/> parameter is null then the default configuration will be used.
        ///
        /// <note type="note">Attempting to open a pool with the same name more than once will result in an error.</note>
        /// </remarks>
        /// <param name="configName">The name of the pool configuration to use.</param>
        /// <param name="config">The runtime configuration to use.</param>
        /// <returns>An asynchronous <see cref="Task{T}"/> that resolves to a Pool instance once the pool is opened.</returns>
        public static Task <Pool> OpenPoolLedgerAsync(string configName, string config)
        {
            ParamGuard.NotNullOrWhiteSpace(configName, "configName");

            var taskCompletionSource = new TaskCompletionSource <Pool>();
            var commandHandle        = PendingCommands.Add(taskCompletionSource);

            var result = IndyNativeMethods.indy_open_pool_ledger(
                commandHandle,
                configName,
                config,
                _openPoolLedgerCallback
                );

            CallbackHelper.CheckResult(result);

            return(taskCompletionSource.Task);
        }