예제 #1
0
        /// <inheritdoc />
        public RestIotaRepository Create(int roundNumber = 0)
        {
            var appSettings = ApplicationSettings.Load();

            nodeUriList.Insert(0, appSettings.IotaNodeUri);

            var iotaClient = new FallbackIotaClient(this.nodeUriList, 5000);

            return(appSettings.DoRemotePoW
               ? new RestIotaRepository(iotaClient, new PoWSrvService())
               : new RestIotaRepository(iotaClient, new PoWService(new CpuPearlDiver())));
        }
        /// <summary>
        /// Creates the repository for multiple circuited nodes
        /// see: https://martinfowler.com/bliki/CircuitBreaker.html
        /// </summary>
        /// <param name="uris">Node Uri List</param>
        /// <param name="powType">"Where" to do the proof of work</param>
        /// <param name="timeout">Timeout for node calls</param>
        /// <returns>
        /// The iota repository
        /// </returns>
        /// <exception>
        /// Throws an UriFormatException if one of the node uris is invalid
        /// </exception>
        public static RestIotaRepository CreateWithFallback(List <string> uris, PoWType powType = PoWType.Local, int timeout = 5000)
        {
            var client = new FallbackIotaClient(uris, timeout);

            return(new RestIotaRepository(client, ResolvePoWType(powType)));
        }