Пример #1
0
        public static BlockChain ToBlockChain(this string json)
        {
            json.Verify(nameof(json)).IsNotEmpty();

            var blockChainModel = JsonConvert.DeserializeObject <BlockChainModel>(json);

            blockChainModel.Blocks.Verify(nameof(blockChainModel.Blocks)).IsNotNull();

            var list = new List <BlockNode>();

            foreach (var node in blockChainModel.Blocks !)
            {
                BlockNode blockNode = node.ConvertTo();
                list.Add(blockNode);
            }

            return(new BlockChain(list));
        }
Пример #2
0
 public BlockNode(BlockNode blockNode)
     : this(blockNode.BlockData, blockNode.Index, blockNode.PreviousHash !)
 {
 }