Example #1
0
        public void Inicializar(DateTime fechatest)
        {
            BlockChain = new List <Bloque>();
            this.i     = 1;
            Bloque gen = new Bloque(0, "00000", "00000", "00000", "00000", fechatest);

            gen.ModHash(Hash256(gen));
            BlockChain.Add(gen);
        }
Example #2
0
        public void AgregarBloque(string pnom, string pmot, string pfhash, DateTime pfech)
        {
            string prehash = GetBloqueIndice(GetI() - 1).GetHash();
            Bloque block   = new Bloque(GetI(), pnom, pmot, pfhash, prehash, pfech);
            string nhash   = HashCondicional(block);

            block.ModHash(nhash);
            BlockChain.Add(block);
            Incrementar_i();
        }
Example #3
0
        public string HashCondicional(Bloque block)
        {
            string phash = Hash256(block);

            if (block.GetFecha().Day % 2 == 0)
            {
                while (phash[0] != '0' | phash[1] != '0')
                {
                    block.IncNonce();
                    phash = Hash256(block);
                }
                return(phash);
            }
            else
            {
                while (phash[0] != '0')
                {
                    block.IncNonce();
                    phash = Hash256(block);
                }
                return(phash);
            }
        }
Example #4
0
 public string Hash256(Bloque pblock)
 {
     return(HashByteToString(pblock.ToByteArray()));
 }