public IActionResult GetFilters([FromQuery, Required] string bestKnownBlockHash, [FromQuery, Required] int count)
        {
            if (count <= 0 || !ModelState.IsValid)
            {
                return(BadRequest("Invalid block hash or count is provided."));
            }

            var knownHash = new uint256(bestKnownBlockHash);

            (Height bestHeight, IEnumerable <FilterModel> filters) = Global.IndexBuilderService.GetFilterLinesExcluding(knownHash, count, out bool found);

            if (!found)
            {
                return(NotFound($"Provided {nameof(bestKnownBlockHash)} is not found: {bestKnownBlockHash}."));
            }

            if (!filters.Any())
            {
                return(NoContent());
            }

            var response = new FiltersResponse
            {
                BestHeight = bestHeight,
                Filters    = filters
            };

            return(Ok(response));
        }
        public async Task GetFiltersAsync(NetworkType networkType)
        {
            using var client = new WasabiClient(LiveServerTestsFixture.UriMappings[networkType], Global.Instance.TorSocks5Endpoint);
            var filterModel = StartingFilters.GetStartingFilter(Network.GetNetwork(networkType.ToString()));

            FiltersResponse filtersResponse = await client.GetFiltersAsync(filterModel.Header.BlockHash, 2);

            Assert.NotNull(filtersResponse);
            Assert.True(filtersResponse.Filters.Count() == 2);
        }
Exemple #3
0
        public async Task GetFiltersAsync(NetworkType networkType)
        {
            using (var client = new WasabiClient(LiveServerTestsFixture.UriMappings[networkType]))
            {
                var filterModel = IndexDownloader.GetStartingFilter(Network.GetNetwork(networkType.ToString()));

                FiltersResponse filtersResponse = await client.GetFiltersAsync(filterModel.BlockHash, 2);

                Assert.NotNull(filtersResponse);
                Assert.True(filtersResponse.Filters.Count() == 2);
            }
        }
Exemple #4
0
        public async Task GetFiltersAsync(NetworkType networkType)
        {
            Network network = (networkType == NetworkType.Mainnet) ? Network.Main : Network.TestNet;

            using var client = new WasabiClient(LiveServerTestsFixture.UriMappings[networkType], Common.TorSocks5Endpoint);
            var filterModel = StartingFilters.GetStartingFilter(network);

            FiltersResponse filtersResponse = await client.GetFiltersAsync(filterModel.Header.BlockHash, 2);

            Assert.NotNull(filtersResponse);
            Assert.True(filtersResponse.Filters.Count() == 2);
        }
        public async Task GetFiltersAsync(NetworkType networkType)
        {
            Network network = (networkType == NetworkType.Mainnet) ? Network.Main : Network.TestNet;

            using var torHttpClient = MakeTorHttpClient(networkType);
            using var client        = new WasabiClient(torHttpClient);

            var filterModel = StartingFilters.GetStartingFilter(network);

            FiltersResponse filtersResponse = await client.GetFiltersAsync(filterModel.Header.BlockHash, 2);

            Assert.NotNull(filtersResponse);
            Assert.True(filtersResponse.Filters.Count() == 2);
        }
Exemple #6
0
        private static async Task AssertFiltersInitializedAsync(RegTestFixture regTestFixture, Backend.Global global)
        {
            var firstHash = await global.RpcClient.GetBlockHashAsync(0);

            while (true)
            {
                using var client = new WasabiClient(new Uri(regTestFixture.BackendEndPoint), null);
                FiltersResponse filtersResponse = await client.GetFiltersAsync(firstHash, 1000);

                Assert.NotNull(filtersResponse);

                var filterCount = filtersResponse.Filters.Count();
                if (filterCount >= 101)
                {
                    break;
                }
                else
                {
                    await Task.Delay(100);
                }
            }
        }