New filter invalidate the cache.
MODIFY
WalletWasabi.Backend/Controllers/BlockchainController.cs
WalletWasabi.Backend/Controllers/BlockchainController.cs
@@ -424,8 +424,11 @@ namespace WalletWasabi.Backend.Controllers
[ProducesResponseType(typeof(StatusResponse), 200)]
public async Task<StatusResponse> GetStatusAsync()
{
- var cacheKey = $"{nameof(GetStatusAsync)}";
+ try
+ {
+ var lastFilter = Global.IndexBuilderService.GetLastFilter();
+ var cacheKey = $"{nameof(GetStatusAsync)}:{lastFilter.Header.BlockHash}";
if (Cache.TryGetValue(cacheKey, out StatusResponse status))
{
return status;
@@ -433,11 +436,7 @@ namespace WalletWasabi.Backend.Controllers
status = new StatusResponse();
- try
- {
- var lastFilter = Global.IndexBuilderService.GetLastFilter();
var lastFilterHash = lastFilter.Header.BlockHash;
-
var bestHash = await RpcClient.GetBestBlockHashAsync();
var lastBlock = await RpcClient.GetBlockAsync(bestHash);
var prevHash = lastBlock.Header.HashPrevBlock;
@@ -450,13 +449,13 @@ namespace WalletWasabi.Backend.Controllers
var cacheEntryOptions = new MemoryCacheEntryOptions().SetAbsoluteExpiration(TimeSpan.FromSeconds(30));
Cache.Set(cacheKey, status, cacheEntryOptions);
+ return status;
}
catch (Exception ex)
{
Logger.LogDebug(ex);
+ throw ex;
}
-
- return status;
}
}
}

MODIFY
WalletWasabi/Blockchain/BlockFilters/IndexBuilderService.cs
WalletWasabi/Blockchain/BlockFilters/IndexBuilderService.cs
@@ -411,7 +411,7 @@ namespace WalletWasabi.Blockchain.BlockFilters
{
using (IndexLock.Lock())
{
- return Index.Last();
+ return Index[^1];
}
}

New filter invalidate the cache.