Beispiel #1
0
 public Block(int index, DateTime timeStamp, BlockDataModel data, string previousHash)
 {
     this.index        = index;
     this.timeStamp    = timeStamp;
     this.previousHash = previousHash;
     this.data         = data;
     using (SHA256 sha256Hash = SHA256.Create())
     {
         hash = Hashier.GetHash(sha256Hash, data);
     }
 }
Beispiel #2
0
 public bool IsValidNewBlock(Block newBlock, Block prevBlock)
 {
     if (prevBlock.Index + 1 != newBlock.Index)
     {
         return(false);
     }
     if (prevBlock.Hash != newBlock.PreviousHash)
     {
         return(false);
     }
     if (Hashier.GetHash(SHA256.Create(), newBlock.Data) != newBlock.Hash)
     {
         return(false);
     }
     return(true);
 }