private static ParityTraceAction DecodeAction(Rlp.DecoderContext context) { ParityTraceAction action = new ParityTraceAction(); int sequenceLength = context.ReadSequenceLength(); if (context.ReadNumberOfItemsRemaining(context.Position + sequenceLength) == 3) { action.CallType = "reward"; action.RewardType = context.DecodeString(); action.Author = context.DecodeAddress(); action.Value = context.DecodeUInt256(); action.TraceAddress = Array.Empty <int>(); } else { action.CallType = context.DecodeString(); action.From = context.DecodeAddress(); action.To = context.DecodeAddress(); action.Value = context.DecodeUInt256(); action.Gas = context.DecodeLong(); action.Input = context.DecodeByteArray(); action.Result = new ParityTraceResult(); action.Result.Output = context.DecodeByteArray(); action.Result.GasUsed = context.DecodeLong(); action.TraceAddress = context.DecodeArray(c => c.DecodeInt()); int subtracesCount = context.DecodeInt(); action.Subtraces = new List <ParityTraceAction>(subtracesCount); for (int i = 0; i < subtracesCount; i++) { action.Subtraces.Add(DecodeAction(context)); } } return(action); }
public HelloMessage Deserialize(byte[] bytes) { Rlp.DecoderContext context = bytes.AsRlpContext(); context.ReadSequenceLength(); HelloMessage helloMessage = new HelloMessage(); helloMessage.P2PVersion = context.DecodeByte(); helloMessage.ClientId = context.DecodeString(); helloMessage.Capabilities = context.DecodeArray(ctx => { ctx.ReadSequenceLength(); string protocolCode = ctx.DecodeString(); int version = ctx.DecodeByte(); return(new Capability(protocolCode, version)); }).ToList(); helloMessage.ListenPort = context.DecodeInt(); helloMessage.NodeId = new PublicKey(context.DecodeByteArray()); return(helloMessage); }