Beispiel #1
0
        private void createGenesisBlock3(ClientN3 client, DAO.Ticket daoTicket, DAO.Block daoBlock)
        {
            log3.Debug("Creating Genesis Block for Node 3");
            DAO.Ticket t1       = daoTicket;
            var        reTicket = client.createTicket(t1);
            Block      block1   = new Block(null, t1);

            daoBlock.PreviousHash = block1.PreviousHash;
            daoBlock.Hash         = block1.Hash;
            daoBlock.Id           = 0;
            daoBlock.IdTicket     = block1.Ticket.Id;
            client.createBlock(daoBlock);
        }
Beispiel #2
0
        /// <summary>
        /// This method is called if the original chain is not null.
        /// </summary>
        /// <param name="node1">First blockchain to compare</param>
        /// <param name="node2">Second blockchain to compare</param>
        /// <param name="node3">Third blockchain to compare</param>
        /// <returns></returns>
        public Boolean nodesValidate(List <Block> node1, List <Block> node2, List <Block> node3)
        {
            Boolean result = false;

            for (int i = 0; i < node1.Count; i++)
            {
                if ((node1[i].CalculateHash() == node2[i].CalculateHash()) & (node2[i].CalculateHash() == node3[i].CalculateHash()))
                {
                    log1.Debug(String.Format("The block # {0} is valid in every chain", i + 1));
                    log2.Debug(String.Format("The block # {0} is valid in every chain", i + 1));
                    log3.Debug(String.Format("The block # {0} is valid in every chain", i + 1));
                    result = true;
                }
                else
                {
                    if (node1[i].CalculateHash() == node2[i].CalculateHash())
                    {
                        log1.Debug(String.Format("The block # {0} is corrupted at chain 3", i + 1));
                        log2.Debug(String.Format("The block # {0} is corrupted at chain 3", i + 1));
                        log3.Debug(String.Format("My block # {0} is corrupted", i + 1));
                    }
                    else
                    {
                        if (node1[i].CalculateHash() == node3[i].CalculateHash())
                        {
                            log1.Debug(String.Format("The block # {0} is corrupted at chain 2", i + 1));
                            log2.Debug(String.Format("My block # {0} is corrupted", i + 1));
                            log3.Debug(String.Format("The block # {0} is corrupted at chain 2", i + 1));
                        }
                        else
                        {
                            if (node2[i].CalculateHash() == node3[i].CalculateHash())
                            {
                                log1.Debug(String.Format("My block # {0} is corrupted", i + 1));
                                log2.Debug(String.Format("The block # {0} is corrupted at chain 1", i + 1));
                                log3.Debug(String.Format("The block # {0} is corrupted at chain 1", i + 1));
                            }
                        }
                    }
                }
            }
            return(result);
        }