コード例 #1
0
        public async Task <IEnumerable <MultiAddress> > ListAddressFiltersAsync(bool persist             = false,
                                                                                CancellationToken cancel = default)
        {
            try
            {
                var json = await _configApi.GetAsync("Swarm.AddrFilters", cancel).ConfigureAwait(false);

                return(json == null ? new MultiAddress[0] : json.Select(a => MultiAddress.TryCreate((string)a)).Where(a => a != null));
            }
            catch (KeyNotFoundException)
            {
                var strings = DefaultFilters.Select(a => a.ToString());
                await _configApi.SetAsync("Swarm.AddrFilters", JToken.FromObject(strings), cancel)
                .ConfigureAwait(false);

                return(DefaultFilters);
            }
        }
コード例 #2
0
ファイル: BootstrapApi.cs プロジェクト: jakubbober/Catalyst
        public async Task <IEnumerable <MultiAddress> > ListAsync(CancellationToken cancel = default)
        {
            if (_discoveryOptions.BootstrapPeers != null)
            {
                return(_discoveryOptions.BootstrapPeers);
            }

            try
            {
                var json = await _configApi.GetAsync("Bootstrap", cancel);

                return(json == null ? new MultiAddress[0] : json.Select(a => MultiAddress.TryCreate((string)a)).Where(a => a != null));
            }
            catch (KeyNotFoundException)
            {
                var strings = Defaults.Select(a => a.ToString());
                await _configApi.SetAsync("Bootstrap", JToken.FromObject(strings), cancel).ConfigureAwait(false);

                return(Defaults);
            }
        }
コード例 #3
0
        public async Task <IGitHubClient> GetClientAsync(CancellationToken cancellationToken)
        {
            if (_gitHubClient != null)
            {
                return(_gitHubClient);
            }

            var token = await _configApi.GetAsync(ConfigKey.With("github-token"), cancellationToken).ConfigureAwait(false);

            if (string.IsNullOrEmpty(token))
            {
                token = Environment.GetEnvironmentVariable("GITHUB_TOKEN");
            }

            var productHeaderValue = new ProductHeaderValue(
                "TheBorg.Plugins.GitHub",
                GetType().Assembly.GetName().Version.ToString());

            _gitHubClient = new GitHubClient(productHeaderValue)
            {
                Credentials = new Credentials(token)
            };
            return(_gitHubClient);
        }
コード例 #4
0
        public async Task Get_Entire_Config()
        {
            var config = await _configApi.GetAsync();

            Assert.That(config["Addresses"]["API"].Value <string>(), Does.StartWith(ApiAddress));
        }