Example #1
0
        public async Task <BigInteger> GetLastConfirmedBlockNumberAsync(BigInteger?waitForConfirmedBlockNumber, CancellationToken cancellationToken)
        {
            var currentBlockOnChain = await GetCurrentBlockOnChain();

            uint attemptCount = 0;

            while (!IsBlockNumberConfirmed(waitForConfirmedBlockNumber, currentBlockOnChain.Value, _minimumBlockConfirmations))
            {
                if (!cancellationToken.IsCancellationRequested)
                {
                    attemptCount++;
                    LogWaitingForBlockAvailability(currentBlockOnChain, _minimumBlockConfirmations, waitForConfirmedBlockNumber, attemptCount);
                    await _waitStrategy.Apply(attemptCount);

                    currentBlockOnChain = await GetCurrentBlockOnChain();
                }
            }

            return(currentBlockOnChain);
        }
 public async Task WaitForNextBlock(int retryNumber)
 {
     await _waitStrategy.Apply(retryNumber);
 }