Ejemplo n.º 1
0
        /// <summary>
        /// Calculates the Proof.
        /// </summary>
        /// <param name="previousProof">The previous Proof.</param>
        /// <param name="currentProof">The current Proof.</param>
        /// <returns></returns>
        private string CalculateProof(int previousProof, int currentProof)
        {
            // this is a random calculation to find out the new Proof which would satisfy the validation criteria
            // in this example I am using (a^2 - b^2 - 2ab)

            return(BlockUtility.GetSha256Hash(String.Format("{0}", (Math.Pow(currentProof, 2) - Math.Pow(previousProof, 2) - 2 * currentProof * previousProof))));
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Calculates the hash.
 /// </summary>
 /// <param name="block">The block.</param>
 /// <returns></returns>
 public string CalculateHash(Block block)
 {
     return(BlockUtility.GetSha256Hash(block.ToString()));
 }