Esempio n. 1
0
        protected override bool ProcessInventoryVector(InventoryVector inv, EndPoint remoteSocketEndpoint)
        {
            if (inv.Type.HasFlag(InventoryType.MSG_TX))
            {
                if (MempoolService.TryGetFromBroadcastStore(inv.Hash, out TransactionBroadcastEntry entry))                 // If we have the transaction then adjust confirmation.
                {
                    if (entry.NodeRemoteSocketEndpoint == remoteSocketEndpoint.ToString())
                    {
                        return(false);                        // Wtf, why are you trying to broadcast it back to us?
                    }

                    entry.ConfirmPropagationForGood();
                }

                // If we already processed it continue.
                if (MempoolService.IsProcessed(inv.Hash))
                {
                    return(false);
                }

                return(true);
            }

            if (inv.Type.HasFlag(InventoryType.MSG_BLOCK))
            {
                BlockInv?.Invoke(this, inv.Hash);
            }

            return(false);
        }
Esempio n. 2
0
        protected override bool ProcessInventoryVector(InventoryVector inv, EndPoint remoteSocketEndpoint)
        {
            if (inv.Type.HasFlag(InventoryType.MSG_TX))
            {
                if (MempoolService.TryGetFromBroadcastStore(inv.Hash, out TransactionBroadcastEntry entry))                 // If we have the transaction then adjust confirmation.
                {
                    if (entry.NodeRemoteSocketEndpoint == remoteSocketEndpoint.ToString())
                    {
                        return(false);                        // Wtf, why are you trying to broadcast it back to us?
                    }

                    entry.ConfirmPropagationOnce();
                }

                // If we already processed it or we're in trusted node mode, then don't ask for it.
                if (MempoolService.TrustedNodeMode || MempoolService.IsProcessed(inv.Hash))
                {
                    return(false);
                }

                return(true);
            }

            return(false);
        }