public async Task Start(TimeSpan checkDelay) { _lastHash = await _nxsClient.GetBlockHashAsync(await _nxsClient.GetBlockCountAsync()); #pragma warning disable 4014 Task.Run(() => StreamAsync(checkDelay), _cancelBlockStream.Token); #pragma warning restore 4014 }
public async Task <BlockDto> GetBlockAsync(int?height, bool includeTransactions) { var blockHeight = height ?? await _nxsClient.GetBlockCountAsync(); var blockHash = await _nxsClient.GetBlockHashAsync(blockHeight); if (blockHash == null) { return(null); } var blockResponse = await _nxsClient.GetBlockAsync(blockHash); if (blockResponse.TransactionHash.Any(string.IsNullOrEmpty)) { throw new KeyNotFoundException($"Block height {blockResponse.Height} has a null transaction"); } return(await MapResponseToDtoAsync(blockResponse, includeTransactions)); }