Skip to content

Commit

Permalink
hard refresh status and disable timer
Browse files Browse the repository at this point in the history
  • Loading branch information
dangershony committed Nov 10, 2023
1 parent 5a731d5 commit 45f9e9f
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 22 deletions.
13 changes: 9 additions & 4 deletions src/Angor/Client/Pages/Settings.razor
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@
{
if (firstRender)
{
await Refresh();
await Refresh(false);
}
}

Expand Down Expand Up @@ -185,7 +185,7 @@
newIndexerLink = string.Empty;
}

await Refresh();
await Refresh(false);
}

private async Task AddRelay()
Expand Down Expand Up @@ -217,7 +217,7 @@
newRelayLink = string.Empty;
}

await Refresh();
await Refresh(false);
}

private void RemoveIndexer(string url)
Expand Down Expand Up @@ -294,10 +294,15 @@
}

private async Task Refresh()
{
await Refresh(true);
}

private async Task Refresh(bool forace)
{
var operationResult = await notificationComponent.LongOperation(async () =>
{
await _networkService.CheckServices();
await _networkService.CheckServices(forace);

return new OperationResult { Success = true };

Expand Down
5 changes: 3 additions & 2 deletions src/Angor/Client/Shared/NavMenu.razor
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
// Convert the version to a string
softwareVersion = version.ToString();

_timer = new Timer(TimerElapsed, null, TimeSpan.Zero, TimeSpan.FromMinutes(5)); // Tick every 5 min
//_timer = new Timer(TimerElapsed, null, TimeSpan.Zero, TimeSpan.FromMinutes(5)); // Tick every 5 min
}

protected override async Task OnInitializedAsync()
Expand All @@ -120,7 +120,8 @@

private void TimerElapsed(object state)
{
_networkService.CheckServices();
// for now we disable the timer because on each call to the indexer capture and update the sate on failures
//_networkService.CheckServices();
}

public void Dispose()
Expand Down
32 changes: 16 additions & 16 deletions src/Angor/Shared/Services/IndexerService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,28 +55,28 @@ public IndexerService(INetworkConfiguration networkConfiguration, HttpClient htt

public async Task<List<ProjectIndexerData>> GetProjectsAsync()
{
var indexer = _networkConfiguration.GetIndexerUrl();
var indexer = _networkService.GetPrimaryIndexer();
// todo: dan - make this proper paging
var response = await _httpClient.GetAsync($"{indexer.Url}/query/Angor/projects?offset=0&limit=50");
var response = await _httpClient.GetAsync($"{indexer.Url}/api/query/Angor/projects?offset=0&limit=50");
_networkService.CheckAndHandleError(response);
response.EnsureSuccessStatusCode();
return await response.Content.ReadFromJsonAsync<List<ProjectIndexerData>>();
}

public async Task<List<ProjectInvestment>> GetInvestmentsAsync(string projectId)
{
var indexer = _networkConfiguration.GetIndexerUrl();
var response = await _httpClient.GetAsync($"{indexer.Url}/query/Angor/projects/{projectId}/investments");
var indexer = _networkService.GetPrimaryIndexer();
var response = await _httpClient.GetAsync($"{indexer.Url}/api/query/Angor/projects/{projectId}/investments");
_networkService.CheckAndHandleError(response);
response.EnsureSuccessStatusCode();
return await response.Content.ReadFromJsonAsync<List<ProjectInvestment>>();
}

public async Task<string> PublishTransactionAsync(string trxHex)
{
var indexer = _networkConfiguration.GetIndexerUrl();
var indexer = _networkService.GetPrimaryIndexer();

var endpoint = Path.Combine(indexer.Url, "command/send");
var endpoint = Path.Combine(indexer.Url, "/api/command/send");

var response = await _httpClient.PostAsync(endpoint, new StringContent(trxHex));
_networkService.CheckAndHandleError(response);
Expand All @@ -92,8 +92,8 @@ public async Task<string> PublishTransactionAsync(string trxHex)
public async Task<AddressBalance[]> GetAdressBalancesAsync(List<AddressInfo> data)
{
//check all new addresses for balance or a history
var urlBalance = "/query/addresses/balance";
var indexer = _networkConfiguration.GetIndexerUrl();
var urlBalance = "/api/query/addresses/balance";
var indexer = _networkService.GetPrimaryIndexer();
var response = await _httpClient.PostAsJsonAsync(indexer.Url + urlBalance,
data.Select(_ => _.Address).ToArray());
_networkService.CheckAndHandleError(response);
Expand All @@ -108,9 +108,9 @@ public async Task<AddressBalance[]> GetAdressBalancesAsync(List<AddressInfo> dat

public async Task<List<UtxoData>?> FetchUtxoAsync(string address, int offset , int limit)
{
SettingsUrl indexer = _networkConfiguration.GetIndexerUrl();
var indexer = _networkService.GetPrimaryIndexer();

var url = $"/query/address/{address}/transactions/unspent?confirmations=0&offset={offset}&limit={limit}";
var url = $"/api/query/address/{address}/transactions/unspent?confirmations=0&offset={offset}&limit={limit}";

var response = await _httpClient.GetAsync(indexer.Url + url);
_networkService.CheckAndHandleError(response);
Expand All @@ -125,9 +125,9 @@ public async Task<AddressBalance[]> GetAdressBalancesAsync(List<AddressInfo> dat

public async Task<FeeEstimations?> GetFeeEstimationAsync(int[] confirmations)
{
SettingsUrl indexer = _networkConfiguration.GetIndexerUrl();
var indexer = _networkService.GetPrimaryIndexer();

var url = confirmations.Aggregate("/stats/fee?", (current, block) => current + $@"confirmations={block}&");
var url = confirmations.Aggregate("/api/stats/fee?", (current, block) => current + $@"confirmations={block}&");

var response = await _httpClient.GetAsync(indexer.Url + url);
_networkService.CheckAndHandleError(response);
Expand All @@ -144,9 +144,9 @@ public async Task<AddressBalance[]> GetAdressBalancesAsync(List<AddressInfo> dat

public async Task<string> GetTransactionHexByIdAsync(string transactionId)
{
SettingsUrl indexer = _networkConfiguration.GetIndexerUrl();
var indexer = _networkService.GetPrimaryIndexer();

var url = $"/query/transaction/{transactionId}/hex";
var url = $"/api/query/transaction/{transactionId}/hex";

var response = await _httpClient.GetAsync(indexer.Url + url);
_networkService.CheckAndHandleError(response);
Expand All @@ -159,9 +159,9 @@ public async Task<string> GetTransactionHexByIdAsync(string transactionId)

public async Task<QueryTransaction?> GetTransactionInfoByIdAsync(string transactionId)
{
SettingsUrl indexer = _networkConfiguration.GetIndexerUrl();
var indexer = _networkService.GetPrimaryIndexer();

var url = $"/query/transaction/{transactionId}";
var url = $"/api/query/transaction/{transactionId}";

var response = await _httpClient.GetAsync(indexer.Url + url);
_networkService.CheckAndHandleError(response);
Expand Down

0 comments on commit 45f9e9f

Please sign in to comment.