public bool Relay(IInventory inventory) { if (inventory is MinerTransaction) { return(false); } if (!CheckKnownHashes(inventory.Hash)) { return(false); } InventoryReceivingEventArgs args = new InventoryReceivingEventArgs(inventory); InventoryReceiving?.Invoke(this, args); if (args.Cancel) { return(false); } if (inventory is Block block) { if (Blockchain.Default == null) { return(false); } if (Blockchain.Default.ContainsBlock(block.Hash)) { return(false); } if (!Blockchain.Default.AddBlock(block)) { return(false); } } else if (inventory is Transaction) { if (!AddTransaction((Transaction)inventory)) { return(false); } } else //if (inventory is Consensus) { if (!inventory.Verify()) { return(false); } } bool relayed = RelayDirectly(inventory); InventoryReceived?.Invoke(this, inventory); return(relayed); }
private void RemoteNode_InventoryReceived(object sender, IInventory inventory) { if (inventory is Transaction tx && tx.Type != TransactionType.ClaimTransaction && tx.Type != TransactionType.IssueTransaction) { if (Blockchain.Default == null) { return; } if (!CheckKnownHashes(inventory.Hash)) { return; } InventoryReceivingEventArgs args = new InventoryReceivingEventArgs(inventory); InventoryReceiving?.Invoke(this, args); if (args.Cancel) { return; } lock (temp_pool) { temp_pool.Add(tx); } new_tx_event.Set(); }