private bool AddTransaction(Transaction tx) { if (Blockchain.Default == null) { return(false); } lock (MemoryPool) { if (MemoryPool.ContainsKey(tx.Hash)) { return(false); } if (Blockchain.Default.ContainsTransaction(tx.Hash)) { return(false); } if (!tx.Verify(MemoryPool.Values)) { return(false); } AddingTransactionEventArgs args = new AddingTransactionEventArgs(tx); AddingTransaction?.Invoke(this, args); if (!args.Cancel) { MemoryPool.Add(tx.Hash, tx); } return(!args.Cancel); } }
private bool AddTransaction(Transaction tx) { if (Blockchain.Default == null) { return(false); } lock (MemoryPool) { if (MemoryPool.ContainsKey(tx.Hash)) { return(false); } if (MemoryPool.Values.SelectMany(p => p.GetAllInputs()).Intersect(tx.GetAllInputs()).Count() > 0) { return(false); } if (Blockchain.Default.ContainsTransaction(tx.Hash)) { return(false); } if (!tx.Verify()) { return(false); } AddingTransactionEventArgs args = new AddingTransactionEventArgs(tx); AddingTransaction?.Invoke(this, args); if (!args.Cancel) { MemoryPool.Add(tx.Hash, tx); } return(!args.Cancel); } }