Beispiel #1
0
 public bool IsChainValid()
 {
     for (int i = 0; i < _chain.Count; i++)
     {
         var hash = VoteHelpers.NextBlockHash(_chain[i]);
         if (_chain[i + 1] != null && hash != _chain[i + 1].previousHash)
         {
             return(false);
         }
     }
     return(true);
 }
Beispiel #2
0
        public VoteBlock AddNewBlock(string data)
        {
            var newBlock = new VoteBlock()
            {
                data         = data,
                index        = _chain.Count + 1,
                timeStamp    = DateTime.Now,
                previousHash = VoteHelpers.NextBlockHash(_chain[_chain.Count - 1])
            };

            _chain.Add(newBlock);
            return(newBlock);
        }