public void WaitForTransaction(BlockIterator iterator, KeyPair keys, Transaction tx, int maxBlocksToWait = 9999) { if (tx == null) { throw new ArgumentNullException(); } WaitForTransaction(iterator, x => x.Hash == tx.Hash, maxBlocksToWait); lastTransactions[keys.address] = tx; }
public Transaction WaitForTransaction(BlockIterator iterator, Func <Transaction, bool> filter, int maxBlocksToWait = 9999) { uint newBlock; while (true) { newBlock = GetBlockHeight(); if (iterator.currentBlock > newBlock) { return(null); } while (iterator.currentBlock <= newBlock) { var block = GetBlock(iterator.currentBlock); if (block != null) { for (uint i = iterator.currentTransaction; i < block.transactions.Length; i++) { var tx = block.transactions[i]; tx.block = block; iterator.currentTransaction++; if (filter(tx)) { return(tx); } } iterator.currentBlock++; iterator.currentTransaction = 0; } } if (maxBlocksToWait == 0) { return(null); } else { maxBlocksToWait--; Thread.Sleep(5000); } } }