public ManualAsyncResult BeginGetUnlockedInfo()
        {
            var asyncResult = new ManualAsyncResult
            {
                Path  = "/account/unlocked/info",
                Bytes = new ASCIIEncoding().GetBytes("{\"Headers\":[{\"Key\":\"Content-Type\",\"Value\":[\"text/plain; charset=utf-8\"]}]}")
            };

            return(new HttpConnector(Connection).PreparePostRequest(asyncResult));
        }
        public ManualAsyncResult BeginGetNearestNodesInfo(SupernodeStructures.Location location)
        {
            var asyncResult = new ManualAsyncResult
            {
                Path  = "/nodes/nearest",
                Bytes = encoding.GetBytes(JsonConvert.SerializeObject(location))
            };

            return(new HttpConnector(Connection).PreparePostRequest(asyncResult));
        }
        public ManualAsyncResult BeginGetTestResults(SupernodeStructures.TestResultRequestData tests)
        {
            var asyncResult = new ManualAsyncResult
            {
                Path  = "/node/testResults",
                Bytes = encoding.GetBytes(JsonConvert.SerializeObject(tests))
            };

            return(new HttpConnector(Connection).PreparePostRequest(asyncResult));
        }
        public ManualAsyncResult BeginGetSupernodes(int status)
        {
            var asyncResult = new ManualAsyncResult
            {
                Path  = "/nodes",
                Bytes = encoding.GetBytes("{\"status\": " + status + "}")
            };

            return(new HttpConnector(Connection).PreparePostRequest(asyncResult));
        }
        public ManualAsyncResult BeginGetSupernodes(Action <ResponseAccessor <SupernodeResponseData.Supernodes> > callback, int status)
        {
            var asyncResult = new ManualAsyncResult
            {
                Path  = "/nodes",
                Bytes = encoding.GetBytes("{\"status\": " + status + "}")
            };

            return(new HttpAsyncConnector(Connection).PreparePostRequestAsync(callback, asyncResult));
        }
        public ManualAsyncResult BeginGetTestResults(Action <ResponseAccessor <SupernodeResponseData.TestResults> > callback, SupernodeStructures.TestResultRequestData tests)
        {
            var asyncResult = new ManualAsyncResult
            {
                Path  = "/node/testResults",
                Bytes = encoding.GetBytes(JsonConvert.SerializeObject(tests))
            };

            return(new HttpAsyncConnector(Connection).PreparePostRequestAsync(callback, asyncResult));
        }
        public void CompletedSynchronouslyPropertySetToFalse()
        {
            // Arrange
            ManualAsyncResult asyncResult = new ManualAsyncResult();

            // Act
            asyncResult.MarkCompleted(false /* completedSynchronously */, null);

            // Assert
            Assert.IsFalse(asyncResult.CompletedSynchronously);
        }
        public void WaitHandlePropertyIsNotSetByDefault()
        {
            // Arrange
            ManualAsyncResult asyncResult = new ManualAsyncResult();

            // Act
            bool wasSet = asyncResult.AsyncWaitHandle.WaitOne(0, false /* exitContext */);

            // Assert
            Assert.IsFalse(wasSet);
        }
Exemple #9
0
        /// <summary>
        /// Gets a sequence of blocks in chronological order from a local node.
        /// </summary>
        /// <remarks>
        /// The request will be refused if attempted with a remote node. if there are less than 10 blocks up to the height given, the number of blocks available will be returned.
        /// </remarks>
        /// <param name="height">The height upto which the sequence of blocks to be retrieved.</param>
        /// <returns>The <see cref="ManualAsyncResult"/> for the asynchronous operation.</returns>
        /// <example>
        /// This sample shows how to use the <see>
        ///         <cref>BeginGetLocalChainPartAsync</cref>
        ///     </see>
        ///     method.
        /// <code>
        /// class TestClass
        /// {
        ///     static void Main()
        ///     {
        ///         Connection connection = new Connection();
        ///
        ///         connection.SetTestnet();
        ///
        ///         BlockClient client = new BlockClient(connection);
        ///
        ///         try
        ///         {
        ///             ManualAsyncResult requestResponse = client.BeginGetLocalChainPartAsync(10000);
        ///         }
        ///         catch (Exception ex) { Console.WriteLine("error: " + ex.Message); }
        ///     }
        /// }
        /// </code>
        /// </example>
        public ManualAsyncResult BeginGetLocalChainPart(int height)
        {
            var asyncResult = new ManualAsyncResult
            {
                Path  = "/local/chain/blocks-after",
                Bytes = encoding.GetBytes(JsonConvert.SerializeObject(new BlockData.BlockHeight {
                    height = height
                }))
            };

            return(new HttpConnector(Connection).PreparePostRequest(asyncResult));
        }
Exemple #10
0
        /// <summary>
        /// Gets a sequence of blocks in chronological order from a local node.
        /// </summary>
        /// <remarks>
        /// The request will be refused if attempted with a remote node. if there are less than 10 blocks up to the height given, the number of blocks available will be returned.
        /// </remarks>
        /// <param name="callback">The action to perfom upon completion of the asynchronous operation.</param>
        /// <param name="height">The height upto which the sequence of blocks to be retrieved.</param>
        /// <returns>The <see cref="ManualAsyncResult"/> for the asynchronous operation.</returns>
        /// <example>
        /// This sample shows how to use the <see>
        ///         <cref>BeginGetLocalChainPartAsync</cref>
        ///     </see>
        ///     method.
        /// <code>
        /// class TestClass
        /// {
        ///     static void Main()
        ///     {
        ///         Connection connection = new Connection();
        ///
        ///         connection.SetTestnet();
        ///
        ///         BlockClient client = new BlockClient(connection);
        ///
        ///         try
        ///         {
        ///             client.BeginGetLocalChainPartAsync(obj =>
        ///             {
        ///                 try
        ///                 {
        ///                     if (obj.Ex != null) throw obj.Ex;
        ///
        ///                     Console.WriteLine("height: " + obj.Content.Data[0].Hash);
        ///                 }
        ///                 catch (Exception e) { Console.WriteLine("error: " + e.Message); }
        ///             }, 10000);
        ///         }
        ///         catch (Exception ex) { Console.WriteLine("error: " + ex.Message); }
        ///     }
        /// }
        /// </code>
        /// </example>
        public ManualAsyncResult BeginGetLocalChainPart(Action <ResponseAccessor <BlockData.BlockList> > callback, int height)
        {
            var asyncResult = new ManualAsyncResult
            {
                Path  = "/local/chain/blocks-after",
                Bytes = encoding.GetBytes(JsonConvert.SerializeObject(new BlockData.BlockHeight {
                    height = height
                }))
            };

            return(new HttpAsyncConnector(Connection).PreparePostRequestAsync(callback, asyncResult));
        }
        public void WaitHandlePropertyIsLazilySetOnCompletion()
        {
            // Arrange
            ManualAsyncResult asyncResult = new ManualAsyncResult();

            asyncResult.MarkCompleted(false, null);

            // Act
            bool wasSet = asyncResult.AsyncWaitHandle.WaitOne(0, false /* exitContext */);

            // Assert
            Assert.IsTrue(wasSet);
        }
        public void IsCompletedProperty()
        {
            // Arrange
            ManualAsyncResult asyncResult = new ManualAsyncResult();

            // Act
            bool isCompletedBefore = asyncResult.IsCompleted;

            asyncResult.MarkCompleted(false, null);
            bool isCompletedAfter = asyncResult.IsCompleted;

            // Assert
            Assert.IsFalse(isCompletedBefore);
            Assert.IsTrue(isCompletedAfter);
        }
        /// <summary>
        /// Gets the  block at the given height in the chain.
        /// </summary>
        /// <param name="callback">The action to perfom upon completion of the asynchronous operation.</param>
        /// <param name="height">The height of the block to be retrieved.</param>
        /// <returns>The <see cref="ManualAsyncResult"/> for the asynchronous operation.</returns>
        /// <example>
        /// This sample shows how to use the <see>
        ///         <cref>BeginGetByHeightAsync</cref>
        ///     </see>
        ///     method.
        /// <code>
        /// class TestClass
        /// {
        ///     static void Main()
        ///     {
        ///         Connection connection = new Connection();
        ///
        ///         connection.SetTestnet();
        ///
        ///         BlockClient client = new BlockClient(connection);
        ///
        ///         try
        ///         {
        ///             client.BeginGetByHeightAsync(obj =>
        ///             {
        ///                 try
        ///                 {
        ///                     if (obj.Ex != null) throw obj.Ex;
        ///
        ///                     Console.WriteLine("height: " + obj.Content.height);
        ///                 }
        ///                 catch (Exception e) { Console.WriteLine("error: " + e.Message); }
        ///             }, 10000);
        ///         }
        ///         catch (Exception ex) { Console.WriteLine("error: " + ex.Message); }
        ///     }
        /// }
        /// </code>
        /// </example>
        public ManualAsyncResult BeginGetByHeight(Action <ResponseAccessor <BlockData.Block> > callback, int height)
        {
            Console.WriteLine(JsonConvert.SerializeObject(new BlockData.BlockHeight {
                height = height
            }));
            var asyncResult = new ManualAsyncResult
            {
                Path  = "/block/at/public/",
                Bytes = encoding.GetBytes(JsonConvert.SerializeObject(new BlockData.BlockHeight {
                    height = height
                }))
            };

            return(new HttpAsyncConnector(Connection).PreparePostRequestAsync(callback, asyncResult));
        }
        public ManualAsyncResult BeginGetNearestNodesInfo(Action <ResponseAccessor <SupernodeResponseData.NearestNodes> > callback, SupernodeStructures.Location location)
        {
            if (location.numNodes > 25)
            {
                throw new ArgumentException("Number of nodes must be 25 or less");
            }

            var asyncResult = new ManualAsyncResult
            {
                Path  = "/nodes/nearest",
                Bytes = encoding.GetBytes(JsonConvert.SerializeObject(location))
            };

            return(new HttpAsyncConnector(Connection).PreparePostRequestAsync(callback, asyncResult));
        }
        public void MarkCompleted()
        {
            // Arrange
            ManualAsyncResult asyncResult = new ManualAsyncResult();
            bool callbackWasCalled        = false;

            AsyncCallback callback = ar => {
                callbackWasCalled = true;
                Assert.AreEqual(asyncResult, ar);
                Assert.IsTrue(ar.CompletedSynchronously);
                Assert.IsTrue(ar.IsCompleted);

                bool wasSignaledBefore = ar.AsyncWaitHandle.WaitOne(0, false /* exitContext */);
                Assert.IsFalse(wasSignaledBefore, "The WaitHandle should not yet have been signaled.");
            };

            // Act
            asyncResult.MarkCompleted(true, callback);
            bool wasSignaledAfter = asyncResult.AsyncWaitHandle.WaitOne(0, false /* exitContext */);

            // Assert
            Assert.IsTrue(callbackWasCalled);
            Assert.IsTrue(wasSignaledAfter);
        }
 /// <summary>
 /// Ends the asynchronous request to get transactions
 /// </summary>
 /// <remarks>
 /// Ends all transaction requests in the transaction client that do not have callbacks.
 /// </remarks>
 /// <param name="result">The <see cref="ManualAsyncResult"/> for the request to be ended.</param>
 /// <returns>The <see cref="Transactions.All"/> instance containing the requested transactions</returns>
 /// <example>
 /// This sample shows how to use the BeginGetXTransaction methods.
 ///
 /// <code>
 /// class TestClass
 /// {
 ///     static void Main()
 ///     {
 ///         Connection connection = new Connection();
 ///
 ///         connection.SetTestnet();
 ///
 ///         TransactionClient client = new TransactionClient(connection);
 ///
 ///         try
 ///         {
 ///             ManualAsyncResult result = client.GetUnconfirmedTransactionsAsync("TCEIV52VWTGUTMYOXYPVTGMGBMQC77EH4MBJRSNT");
 ///
 ///             Transactions.All transactions = client.EndGetTransactions(result);
 ///         }
 ///         catch (Exception ex)
 ///         {
 ///             Console.WriteLine("error: " + ex.Message);
 ///         }
 ///     }
 /// }
 /// </code>
 /// </example>
 public Transactions.All EndGetTransactions(ManualAsyncResult result)
 {
     return(new HttpConnector(Connection).CompleteGetRequest <Transactions.All>(result));
 }
Exemple #17
0
 public NodeList EndGetReachablePeerList(ManualAsyncResult result)
 {
     return(new HttpConnector(Connection).CompleteGetRequest <NodeList>(result));
 }
Exemple #18
0
 ///  <summary>
 ///  Ends an asynchronous request to get the importances information.
 ///  </summary>
 /// <returns>An <see cref=" Importances.ListImportances"/> object</returns>
 ///  <example>
 ///  This sample shows how to use the <see>
 ///          <cref>EndGetImportances</cref>
 ///      </see>
 ///      method.
 ///  <code>
 ///  class TestClass
 ///  {
 ///      static void Main()
 ///      {
 ///          Connection connection = new Connection();
 ///
 ///          connection.SetTestnet();
 ///
 ///          AccountClient client = new AccountClient(connection);
 ///
 ///          try
 ///          {
 ///              ManualAsyncResult requestResponse = client.BeginGetImportances();
 ///
 ///              Importances.ListImportances data = client.EndGetImportances(requestResponse);
 ///
 ///          }
 ///          catch (Exception ex) { Console.WriteLine("error: " + ex.Message); }
 ///      }
 ///  }
 ///  </code>
 ///  </example>
 public Importances.ListImportances EndGetImportances(ManualAsyncResult result)
 {
     return(new HttpConnector(Connection).CompleteGetRequest <Importances.ListImportances>(result));
 }
Exemple #19
0
 public BlockData.BlockHeight EndGetMaxHeightList(ManualAsyncResult result)
 {
     return(new HttpConnector(Connection).CompleteGetRequest <BlockData.BlockHeight>(result));
 }
Exemple #20
0
 /// <summary>
 /// Ends an asynchronous request to get the status of a given account.
 /// </summary>
 /// <param name="result">The <see cref="ManualAsyncResult"/> result from the BeginGetAccountStatus method.</param>
 /// <returns>A <see cref="AccountStatus"/> returned from the reqeust</returns>
 /// <example>
 /// This sample shows how to use the <see cref="EndGetAccountStatus"/> method.
 /// <code>
 /// class TestClass
 /// {
 ///     static void Main()
 ///     {
 ///         Connection connection = new Connection();
 ///
 ///         connection.SetTestnet();
 ///
 ///         AccountClient client = new AccountClient(connection);
 ///
 ///          try
 ///          {
 ///             ManualAsyncResult requestResponse = client.BeginGetAccountRootFromPublicKey("09ac855e55fad630bdfbd52e08c54e520524e6f9bbd14844a2b0ecca66cae6a0");
 ///
 ///             AccountForwarded.Data accountData = client.EndGetAccountRoot(requestResponse);
 ///
 ///           }
 ///          catch (Exception ex) { Console.WriteLine("error: " + ex.Message); }
 ///     }
 /// }
 /// </code>
 /// </example>
 public AccountStatus EndGetAccountStatus(ManualAsyncResult result)
 {
     return(new HttpConnector(Connection).CompleteGetRequest <AccountStatus>(result));
 }
Exemple #21
0
 public NodeCollection EndGetPeerList(ManualAsyncResult result)
 {
     return(new HttpConnector(Connection).CompleteGetRequest <NodeCollection>(result));
 }
Exemple #22
0
 /// <summary>
 /// Ends an asynchronous request to get account information from a given public key
 /// </summary>
 /// <remarks>
 /// This method is used to get the result from all of the BeginGetAccountInfoFromX methods except the overload that allows for a callback.
 /// </remarks>
 /// <param name="result">The <see cref="ManualAsyncResult"/> result from any of the GetAccountFrom methods</param>
 /// <returns>A <see cref="ExistingAccount.Data "/> returned from the reqeust</returns>
 /// <example>
 /// This sample shows how to use the <see cref="EndGetAccountInfo"/> method.
 /// <code>
 /// class TestClass
 /// {
 ///     static void Main()
 ///     {
 ///         Connection connection = new Connection();
 ///
 ///         connection.SetTestnet();
 ///
 ///         AccountClient client = new AccountClient(connection);
 ///
 ///         try
 ///         {
 ///             ManualAsyncResult result = client.BeginGetAccountInfoFromPublicKey("09ac855e55fad630bdfbd52e08c54e520524e6f9bbd14844a2b0ecca66cae6a0");
 ///
 ///             ExistingAccount.Data data = client.EndGetAccountInfo(result);
 ///         }
 ///         catch (Exception ex)
 ///         {
 ///              Console.WriteLine("6 callback: error: " + ex.Message);
 ///        }
 ///     }
 /// }
 /// </code>
 /// </example>
 public ExistingAccount.Data EndGetAccountInfo(ManualAsyncResult result)
 {
     return(new HttpConnector(Connection).CompleteGetRequest <ExistingAccount.Data>(result));
 }
Exemple #23
0
 /// <summary>
 /// Ends an asynchronous request to get the account root information from a given public key or address
 /// </summary>
 /// <remarks>
 /// This method is used to get the result from all of the BeginGetAccountRootFromX methods except the overload that allows for a callback.
 /// </remarks>
 /// <param name="result">The <see cref="ManualAsyncResult"/> result from any of the BeginGetAccountRootFromX methods</param>
 /// <returns>A <see cref="AccountForwarded.Data"/> returned from the reqeust</returns>
 /// <example>
 /// This sample shows how to use the <see cref="EndGetAccountRoot"/> method.
 /// <code>
 /// class TestClass
 /// {
 ///     static void Main()
 ///     {
 ///         Connection connection = new Connection();
 ///
 ///         connection.SetTestnet();
 ///
 ///         AccountClient client = new AccountClient(connection);
 ///
 ///          try
 ///          {
 ///             ManualAsyncResult requestResponse = client.BeginGetAccountRootFromPublicKey("09ac855e55fad630bdfbd52e08c54e520524e6f9bbd14844a2b0ecca66cae6a0");
 ///
 ///             AccountForwarded.Data accountData = client.EndGetAccountRoot(requestResponse);
 ///
 ///           }
 ///          catch (Exception ex) { Console.WriteLine("error: " + ex.Message); }
 ///     }
 /// }
 /// </code>
 /// </example>
 public AccountForwarded.Data EndGetAccountRoot(ManualAsyncResult result)
 {
     return(new HttpConnector(Connection).CompleteGetRequest <AccountForwarded.Data>(result));
 }
Exemple #24
0
 ///  <summary>
 ///  Ends an asynchronous request to get historical information about an account.
 ///  </summary>
 /// <returns>An <see cref=" HistoricData"/> object</returns>
 ///  <example>
 ///  This sample shows how to use the <see>
 ///          <cref>BeginGetHistoricData</cref>
 ///      </see>
 ///      method.
 ///  <code>
 ///  class TestClass
 ///  {
 ///      static void Main()
 ///      {
 ///          Connection connection = new Connection();
 ///
 ///          connection.SetTestnet();
 ///
 ///          AccountClient client = new AccountClient(connection);
 ///
 ///           try
 ///          {
 ///              client.Connection.SetHost("34.211.28.210"); // node that accepts historical requests at time of writing
 ///
 ///              ManualAsyncResult requestResponse = client.BeginGetHistoricData("TCEIV52VWTGUTMYOXYPVTGMGBMQC77EH4MBJRSNT", 100, 200, 1);
 ///
 ///              HistoricalData data = client.EndGetHistoricalData(requestResponse);
 ///          }
 ///          catch (Exception ex) { Console.WriteLine(" error: " + ex.Message); }
 ///      }
 ///  }
 ///  </code>
 ///  </example>
 public HistoricData EndGetHistoricalData(ManualAsyncResult result)
 {
     return(new HttpConnector(Connection).CompleteGetRequest <HistoricData>(result));
 }
Exemple #25
0
 /// <summary>
 /// Ends the asynchronous request to get the status of the Nis.
 /// </summary>
 /// <returns>The <see cref="ManualAsyncResult"/> for the request.</returns>
 /// <example>
 /// This sample shows how to use the <see>
 ///         <cref>EndGetStatus</cref>
 ///     </see>
 ///     method.
 /// <code>
 /// class TestClass
 /// {
 ///     static void Main()
 ///     {
 ///         Connection connection = new Connection();
 ///
 ///         connection.SetTestnet();
 ///
 ///         NisClient client = new NisClient(connection);
 ///
 ///         try
 ///         {
 ///             ManualAsyncResult result = client.BeginGetStatus();
 ///
 ///             Status stat = client.EndGetStatus(result);
 ///         }
 ///         catch (Exception ex) { Console.WriteLine("error: " + ex.Message); }
 ///     }
 /// }
 /// </code>
 /// </example>
 public NemRequestResult EndGetStatus(ManualAsyncResult result)
 {
     return(new HttpConnector(Connection).CompleteGetRequest <NemRequestResult>(result));
 }
Exemple #26
0
 public UnlockedInfo EndGetUnlockedInfo(ManualAsyncResult result)
 {
     return(new HttpConnector(Connection).CompletePostRequest <UnlockedInfo>(result));
 }
 public SupernodeResponseData.Supernodes EndGetSupernodes(ManualAsyncResult result)
 {
     return(new HttpConnector(Connection).CompleteGetRequest <SupernodeResponseData.Supernodes>(result));
 }
Exemple #28
0
 /// <summary>
 /// Ends an asynchronous request to get the account root information from a given public key or address
 /// </summary>
 /// <remarks>
 /// This method is used to get the result from the BeginGetHarvestingInfo method.
 /// </remarks>
 /// <param name="result">The <see cref="ManualAsyncResult"/> result from the BeginGetHarvestingInfo method</param>
 /// <returns>A <see cref="HarvestingData.ListData"/> returned from the reqeust</returns>
 /// <example>
 /// This sample shows how to use the <see cref="EndGetHarvestingInfo"/> method.
 /// <code>
 /// class TestClass
 /// {
 ///     static void Main()
 ///     {
 ///         Connection connection = new Connection();
 ///
 ///         connection.SetTestnet();
 ///
 ///         AccountClient client = new AccountClient(connection);
 ///
 ///          try
 ///          {
 ///             ManualAsyncResult requestResponse = client.BeginGetHarvestingInfo("TCEIV52VWTGUTMYOXYPVTGMGBMQC77EH4MBJRSNT");
 ///
 ///             AccountForwarded.Data accountData = client.EndGetHarvestingInfo(requestResponse);
 ///
 ///           }
 ///          catch (Exception ex) { Console.WriteLine("error: " + ex.Message); }
 ///     }
 /// }
 /// </code>
 /// </example>
 public HarvestingData.ListData EndGetHarvestingInfo(ManualAsyncResult result)
 {
     return(new HttpConnector(Connection).CompleteGetRequest <HarvestingData.ListData>(result));
 }
Exemple #29
0
 public NodeAndNis EndGetExtendedNodeInfo(ManualAsyncResult result)
 {
     return(new HttpConnector(Connection).CompleteGetRequest <NodeAndNis>(result));
 }
Exemple #30
0
 public NodeData EndGetNodeInfo(ManualAsyncResult result)
 {
     return(new HttpConnector(Connection).CompleteGetRequest <NodeData>(result));
 }