public static (ChainedBlock ChainedBlock, Block Block) AppendBlock(ChainedBlock previous, ConcurrentChain chain)
        {
            ChainedBlock last  = null;
            var          nonce = RandomUtils.GetUInt32();
            var          block = new Block();

            block.AddTransaction(new Transaction());
            block.UpdateMerkleRoot();
            block.Header.HashPrevBlock = previous == null ? chain.Tip.HashBlock : previous.HashBlock;
            block.Header.Nonce         = nonce;
            if (!chain.TrySetTip(block.Header, out last))
            {
                throw new InvalidOperationException("Previous not existing");
            }

            return(last, block);
        }
        public static Block AppendTransactionInNewBlockToChain(ConcurrentChain chain, Transaction transaction)
        {
            ChainedBlock last  = null;
            var          nonce = RandomUtils.GetUInt32();
            var          block = new Block();

            block.AddTransaction(transaction);
            block.UpdateMerkleRoot();
            block.Header.HashPrevBlock = chain.Tip.HashBlock;
            block.Header.Nonce         = nonce;
            if (!chain.TrySetTip(block.Header, out last))
            {
                throw new InvalidOperationException("Previous not existing");
            }

            return(block);
        }
        private ChainedHeader AppendBlock(ChainedHeader previous, params ConcurrentChain[] chains)
        {
            ChainedHeader last  = null;
            uint          nonce = RandomUtils.GetUInt32();

            foreach (ConcurrentChain chain in chains)
            {
                Block block = this.network.CreateBlock();
                block.AddTransaction(this.network.CreateTransaction());
                block.UpdateMerkleRoot();
                block.Header.HashPrevBlock = previous == null ? chain.Tip.HashBlock : previous.HashBlock;
                block.Header.Nonce         = nonce;
                if (!chain.TrySetTip(block.Header, out last))
                {
                    throw new InvalidOperationException("Previous not existing");
                }
            }
            return(last);
        }