public ChainLevelInfo Decode(Rlp.DecoderContext context, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { if (context.IsNextItemNull()) { return(null); } int lastCheck = context.ReadSequenceLength() + context.Position; bool hasMainChainBlock = context.DecodeBool(); List <BlockInfo> blockInfos = new List <BlockInfo>(); context.ReadSequenceLength(); while (context.Position < lastCheck) { blockInfos.Add(Rlp.Decode <BlockInfo>(context, RlpBehaviors.AllowExtraData)); } if (!rlpBehaviors.HasFlag(RlpBehaviors.AllowExtraData)) { context.Check(lastCheck); } ChainLevelInfo info = new ChainLevelInfo(hasMainChainBlock, blockInfos.ToArray()); return(info); }
public BlockInfo Decode(Rlp.DecoderContext context, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { int lastCheck = context.ReadSequenceLength() + context.Position; BlockInfo blockInfo = new BlockInfo(); blockInfo.BlockHash = context.DecodeKeccak(); blockInfo.WasProcessed = context.DecodeBool(); blockInfo.TotalDifficulty = context.DecodeUInt256(); blockInfo.TotalTransactions = context.DecodeUInt256(); if (!rlpBehaviors.HasFlag(RlpBehaviors.AllowExtraData)) { context.Check(lastCheck); } return(blockInfo); }