public static void WaitForTransaction(this LongPollingNotificationSession session, TrackedSource trackedSource, uint256 txId) { using (var cts = new CancellationTokenSource(TimeSpan.FromSeconds(10))) { while (true) { if (session.NextEvent(cts.Token) is NewTransactionEvent evts) { if (evts.TrackedSource == trackedSource && evts.TransactionData.TransactionHash == txId) { break; } } } } }
public static void WaitForBlocks(this LongPollingNotificationSession session, params uint256[] txIds) { if (txIds == null || txIds.Length == 0) { return; } HashSet <uint256> txidsSet = new HashSet <uint256>(txIds); using (var cts = new CancellationTokenSource(TimeSpan.FromSeconds(20))) { while (true) { if (session.NextEvent(cts.Token) is NewBlockEvent evts) { txidsSet.Remove(evts.Hash); if (txidsSet.Count == 0) { break; } } } } }