public async Task AddTransaction(Transaction transaction) { if (transaction == null) { throw new ArgumentNullException(nameof(transaction)); } if (_unverifiedTransactionPool.ContainsKey(transaction.Hash)) { throw new InvalidTransactionException($"The transaction \"{transaction.Hash.ToString(true)}\" was already queued and still not verified to be added."); } if (_verifiedTransactionPool.Contains(transaction.Hash)) { throw new InvalidTransactionException($"The transaction \"{transaction.Hash.ToString(true)}\" was already queued and verified to be added."); } if (await _repository.GetTransaction(transaction.Hash) != null) { throw new InvalidTransactionException($"The transaction \"{transaction.Hash.ToString(true)}\" exists already on the blockchain."); } if (!_unverifiedTransactionPool.TryAdd(transaction.Hash, transaction)) { throw new InvalidTransactionException($"The transaction \"{transaction.Hash.ToString(true)}\" was already queued to be added."); } }