Skip to content

Commit

Permalink
fb
Browse files Browse the repository at this point in the history
  • Loading branch information
kiminuo committed Mar 15, 2024
1 parent 9975500 commit 70a9b75
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions WalletWasabi.Backend/Controllers/BlockchainController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class BlockchainController : ControllerBase
{
public static readonly TimeSpan FilterTimeout = TimeSpan.FromMinutes(20);
private static readonly MemoryCacheEntryOptions CacheEntryOptions = new() { AbsoluteExpirationRelativeToNow = TimeSpan.FromSeconds(60) };
private static MemoryCacheEntryOptions TransactionCacheOptions { get; } = new MemoryCacheEntryOptions { AbsoluteExpirationRelativeToNow = TimeSpan.FromMinutes(1) };
private static MemoryCacheEntryOptions TransactionCacheOptions { get; } = new MemoryCacheEntryOptions { AbsoluteExpirationRelativeToNow = TimeSpan.FromMinutes(20) };

public BlockchainController(IMemoryCache memoryCache, Global global)
{
Expand Down Expand Up @@ -143,10 +143,10 @@ private async Task<IEnumerable<string>> GetRawMempoolStringsNoCacheAsync(Cancell
[HttpGet("transaction-hexes")]
[ProducesResponseType(200)]
[ProducesResponseType(400)]
public async Task<IActionResult> GetTransactionsAsync([FromQuery, Required] List<string> transactionIds, CancellationToken cancellationToken)
public async Task<IActionResult> GetTransactionsAsync([FromQuery, Required] IEnumerable<string> transactionIds, CancellationToken cancellationToken)
{
const int MaxTxToRequest = 10;
int requestCount = transactionIds.Count;
int requestCount = transactionIds.Count();

if (requestCount > MaxTxToRequest)
{
Expand All @@ -165,10 +165,18 @@ public async Task<IActionResult> GetTransactionsAsync([FromQuery, Required] List
return BadRequest("Invalid transaction Ids.");
}

Transaction[] txs = await FetchTransactionsAsync(parsedTxIds, cancellationToken).ConfigureAwait(false);
string[] hexes = txs.Select(x => x.ToHex()).ToArray();
try
{
Transaction[] txs = await FetchTransactionsAsync(parsedTxIds, cancellationToken).ConfigureAwait(false);
string[] hexes = txs.Select(x => x.ToHex()).ToArray();

return Ok(hexes);
return Ok(hexes);
}
catch (Exception ex)
{
Logger.LogDebug(ex);
return BadRequest(ex.Message);
}
}

/// <summary>
Expand Down

0 comments on commit 70a9b75

Please sign in to comment.