Example #1
0
        /// <summary>
        /// Add next valid block
        /// </summary>
        /// <param name="block"></param>
        /// <returns></returns>
        public NodeIndex Add(Block block)
        {
            IReadOnlyList <IUserOrder>          newOrders;
            IReadOnlyList <IAssigningUserOrder> assigningOrders;

            GetOngoingUserOrders(block.Transactions, out newOrders, out assigningOrders);

            if (IsEmpty)
            {
                return(new NodeIndex(BlocksIndex.New(block), OrdersIndex.New(newOrders), UsersIndex.New(newOrders)));
            }

            var newBlocks       = Blocks.Add(block);
            var newTransactions = Orders.Add(newOrders, assigningOrders);
            var newUsers        = Users.Add(newOrders, assigningOrders);

            return(new NodeIndex(newBlocks, newTransactions, newUsers));
        }
Example #2
0
 private NodeIndex(BlocksIndex blocks, OrdersIndex orders, UsersIndex users)
 {
     Blocks = blocks ?? throw new ArgumentNullException("blocks");
     Orders = orders ?? throw new ArgumentNullException("orders");
     Users  = users ?? throw new ArgumentNullException("users");
 }