private void TransferTxs(GetTxs getTxs) { foreach (TxId txid in getTxs.TxIds) { try { Transaction <T> tx = BlockChain.GetTransaction(txid); if (tx is null) { continue; } Message response = new Messages.Tx(tx.Serialize(true)) { Identity = getTxs.Identity, }; Transport.ReplyMessage(response); } catch (KeyNotFoundException) { _logger.Warning("Requested TxId {TxId} does not exist.", txid); } } }
private void TransferTxs(GetTxs getTxs) { IEnumerable <Transaction <T> > txs = getTxs.TxIds .Where(txId => _store.ContainsTransaction(txId)) .Select(BlockChain.GetTransaction); foreach (Transaction <T> tx in txs) { Message response = new Messages.Tx(tx.Serialize(true)) { Identity = getTxs.Identity, }; Transport.ReplyMessage(response); } }
private void TransferTxs(GetTxs getTxs) { foreach (TxId txid in getTxs.TxIds) { Transaction <T> tx = BlockChain.GetTransaction(txid); if (tx is null) { continue; } Message response = new Messages.Tx(tx.Serialize(true)) { Identity = getTxs.Identity, }; Transport.ReplyMessage(response); } }
private async Task TransferTxs <T>( Blockchain <T> blockchain, GetTxs getTxs, CancellationToken cancellationToken) where T : IAction { IDictionary <TxId, Transaction <T> > txs = blockchain.Transactions; foreach (var txid in getTxs.TxIds) { if (txs.TryGetValue(txid, out Transaction <T> tx)) { Message response = new Messages.Tx(tx.ToBencodex(true)) { Identity = getTxs.Identity, }; await ReplyAsync(response, cancellationToken); } } }