Exemplo n.º 1
0
        private bool HandleBlock(Chain chain, Block block, IList <Transaction> transactions)
        {
            try
            {
                var oracle    = new BlockOracleReader(Nexus, block);
                var changeSet = chain.ProcessTransactions(block, transactions, oracle, 1, false); // false, because we don't want to modify the block

                chain.AddBlock(block, transactions, 1, changeSet);
            }
            catch (Exception e)
            {
                Logger.Error(e.ToString());
                throw new Exception("block add failed");
            }

            Logger.Message($"Added block #{block.Height} to {chain.Name}");
            return(true);
        }
Exemplo n.º 2
0
        private bool HandleBlock(Chain chain, Block block, IList <Transaction> transactions)
        {
            if (block.Height != chain.Height + 1)
            {
                throw new NodeException("unexpected block height");
            }

            try
            {
                var         oracle = new BlockOracleReader(Nexus, block);
                Transaction inflationTx;
                var         changeSet = chain.ProcessTransactions(block, transactions, oracle, 1, out inflationTx, null); // null, because we don't want to modify the block

                chain.AddBlock(block, transactions, 1, changeSet);
            }
            catch (Exception e)
            {
                Logger.Error(e.ToString());
                throw new NodeException($"Failed to add block {block.Height} to {chain.Name} chain");
            }

            return(true);
        }