NicolasDorier/NBitcoin — pull request #13 by dthorpe (2014-10-17 19:14:18+00:00)
Title: New RPCClientAsync class

New RPCClientAsync class which uses async/await pattern everywhere, to get more throughput with fewer blocking threads. Uses HttpClient internally to make requests and serialize JSON.

The Json serialization of the RPCRequest and RPCResponse are handled by the HttpClient built-in json serializers, To get the json-rpc member names right, I added DataMember attributes to the properties of RPCRequest. If having RPCRequest and RPCResponse (and RPCError) cohabiting two different serialization models is too weird, I can create separate dto classes for the HttpClient based RPCClientAsync.

Note that yield return for IEnumerable generators (for RPCClientAsync:GetTransactions) doesn't mesh well with the TAP async/await pattern. It can be solved using Rx.NET Observable (to create an asynchronous generator of enumerable items) but that will require adding Rx.NET as a dependency to NBitcoin. For the moment, RPCClientAsync:GetTransactions is implemented as a synchronous operation. Each call to the enumerator.Next will internally make a blocking network call to fetch the raw transaction.

Opinions?