Exemplo n.º 1
0
 private void OnInventoryReceived(IInventory inventory)
 {
     TR.Enter();
     lock (missions_global)
     {
         lock (missions)
         {
             missions_global.Remove(inventory.Hash);
             missions.Remove(inventory.Hash);
             if (missions.Count == 0)
             {
                 mission_start = DateTime.Now.AddYears(100);
             }
             else
             {
                 mission_start = DateTime.Now;
             }
         }
     }
     if (inventory is MinerTransaction)
     {
         TR.Exit(); return;
     }
     InventoryReceived?.Invoke(this, inventory);
     TR.Exit();
 }
Exemplo n.º 2
0
 public void Handle(InventoryReceived domainEvent)
 {
     Process(domainEvent, e =>
     {
         QuantityAvailable += e.Quantity;
     });
 }
Exemplo n.º 3
0
 private void OnInventoryReceived(Inventory inventory)
 {
     lock (missions_global)
     {
         missions_global.Remove(inventory.Hash);
     }
     missions.Remove(inventory.Hash);
     InventoryReceived?.Invoke(this, inventory);
 }
Exemplo n.º 4
0
        public bool Relay(IInventory inventory)
        {
            if (inventory is MinerTransaction)
            {
                return(false);
            }
            lock (KnownHashes)
            {
                if (!KnownHashes.Add(inventory.Hash))
                {
                    return(false);
                }
            }
            InventoryReceivingEventArgs args = new InventoryReceivingEventArgs(inventory);

            InventoryReceiving?.Invoke(this, args);
            if (args.Cancel)
            {
                return(false);
            }
            if (inventory is Block)
            {
                if (Blockchain.Default == null)
                {
                    return(false);
                }
                Block block = (Block)inventory;
                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);
        }
Exemplo n.º 5
0
 private void OnInventoryReceived(IInventory inventory)
 {
     lock (missions_global)
     {
         missions_global.Remove(inventory.Hash);
     }
     missions.Remove(inventory.Hash);
     if (inventory is MinerTransaction)
     {
         return;
     }
     InventoryReceived?.Invoke(this, inventory);
 }
 /// <summary>
 /// Provides a safe way to invoke the <see cref="InventoryReceived" /> event.
 /// </summary>
 /// <param name="value"></param>
 public void RaiseInventoryReceived(GetInventoryResponse value) => InventoryReceived?.Invoke(this, value);