Skip to content

Commit

Permalink
refactor: allow follow tip to accept null intersection (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mercurial authored Nov 24, 2024
1 parent 9d3b99f commit 41db254
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions src/Utxorpc.Sdk/SyncServiceClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public SyncServiceClient(string url, IDictionary<string, string>? headers = null
{
var httpClientHandler = new HttpClientHandler();
var httpClient = new HttpClient(httpClientHandler);

if (headers != null)
{
foreach (var header in headers)
Expand All @@ -36,7 +36,7 @@ public SyncServiceClient(string url, IDictionary<string, string>? headers = null

public async Task<Block?> FetchBlockAsync(BlockRef blockRef)
{
FetchBlockRequest? request = new()
FetchBlockRequest request = new()
{
Ref = { DataUtils.ToSyncBlockRef(blockRef) }
};
Expand All @@ -46,12 +46,19 @@ public SyncServiceClient(string url, IDictionary<string, string>? headers = null
return DataUtils.FromAnyChainBlock(anyChainBlock);
}

public async IAsyncEnumerable<NextResponse> FollowTipAsync(BlockRef blockRef)
public async IAsyncEnumerable<NextResponse> FollowTipAsync(BlockRef? blockRef = null)
{
FollowTipRequest? request = new()

FollowTipRequest request;

if (blockRef is not null)
{
Intersect = { DataUtils.ToSyncBlockRef(blockRef) }
};
request = new() { Intersect = { DataUtils.ToSyncBlockRef(blockRef) } };
}
else
{
request = new();
}

using AsyncServerStreamingCall<FollowTipResponse>? call = _client.FollowTip(request);
await foreach (FollowTipResponse? response in call.ResponseStream.ReadAllAsync())
Expand Down

0 comments on commit 41db254

Please sign in to comment.