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); }
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(); }
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); } }
public string Hash256(Bloque pblock) { return(HashByteToString(pblock.ToByteArray())); }