示例#1
0
        /// <summary>
        /// 从Json生成
        /// </summary>
        /// <param name="jsonData"></param>
        /// <returns></returns>
        public static MBlock FormJson(string jsonData)
        {
            var block = new MBlock();

            JsonConvert.PopulateObject(jsonData, block);
            if (block.Hash != block.GetHash())
            {
                return(null);
            }
            return(block);
        }
示例#2
0
 /// <summary>
 /// 是否为下一个区块
 /// </summary>
 /// <param name="nextBlock"></param>
 /// <returns></returns>
 public bool IsNextBlock(MBlock nextBlock)
 {
     if (Index != nextBlock.Index - 1)
     {
         return(false);
     }
     if (Hash != nextBlock.PrevHash)
     {
         return(false);
     }
     if (nextBlock.GetHash() != nextBlock.Hash)
     {
         return(false);
     }
     return(true);
 }