public FaucetResponse Decode(RlpStream rlpStream, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { rlpStream.ReadSequenceLength(); FaucetRequestStatus status = (FaucetRequestStatus)rlpStream.DecodeInt(); FaucetRequestDetails request = Serialization.Rlp.Rlp.Decode <FaucetRequestDetails>(rlpStream); return(new FaucetResponse(status, request)); }
public static GetReceiptsMessage Deserialize(RlpStream rlpStream) { GetReceiptsMessage getReceiptsMessage = new GetReceiptsMessage(); rlpStream.ReadSequenceLength(); getReceiptsMessage.RequestId = rlpStream.DecodeLong(); getReceiptsMessage.EthMessage = Eth.V63.GetReceiptsMessageSerializer.Deserialize(rlpStream); return(getReceiptsMessage); }
public DataDeliveryReceiptToMerge Decode(RlpStream rlpStream, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { rlpStream.ReadSequenceLength(); UnitsRange unitsRange = Serialization.Rlp.Rlp.Decode <UnitsRange>(rlpStream); Signature signature = SignatureDecoder.DecodeSignature(rlpStream); return(new DataDeliveryReceiptToMerge(unitsRange, signature)); }
private static NewBlockMessage Deserialize(RlpStream rlpStream) { NewBlockMessage message = new NewBlockMessage(); rlpStream.ReadSequenceLength(); message.Block = Rlp.Decode <Block>(rlpStream); message.TotalDifficulty = rlpStream.DecodeUInt256(); return(message); }
public ParityLikeTxTrace Decode(RlpStream rlpStream, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { ParityLikeTxTrace trace = new ParityLikeTxTrace(); rlpStream.ReadSequenceLength(); trace.BlockHash = rlpStream.DecodeKeccak(); trace.BlockNumber = (long)rlpStream.DecodeUInt256(); trace.TransactionHash = rlpStream.DecodeKeccak(); Span <byte> txPosBytes = rlpStream.DecodeByteArraySpan(); trace.TransactionPosition = txPosBytes.Length == 0 ? (int?)null : txPosBytes.ReadEthInt32(); rlpStream.ReadSequenceLength(); trace.Action = DecodeAction(rlpStream); trace.StateChanges = DecodeStateDiff(rlpStream); // stateChanges return(trace); }
private static GetBlockHeadersMessage Deserialize(RlpStream rlpStream) { GetBlockHeadersMessage getBlockHeadersMessage = new(); rlpStream.ReadSequenceLength(); getBlockHeadersMessage.RequestId = rlpStream.DecodeLong(); getBlockHeadersMessage.EthMessage = Eth.V62.Messages.GetBlockHeadersMessageSerializer.Deserialize(rlpStream); return(getBlockHeadersMessage); }
public DataAssetStateChangedMessage Deserialize(byte[] bytes) { RlpStream context = bytes.AsRlpStream(); context.ReadSequenceLength(); Keccak? dataAssetId = context.DecodeKeccak(); DataAssetState state = (DataAssetState)context.DecodeInt(); return(new DataAssetStateChangedMessage(dataAssetId, state)); }
public PingMsg Deserialize(byte[] msgBytes) { (PublicKey FarPublicKey, byte[] Mdc, byte[] Data)results = PrepareForDeserialization(msgBytes); RlpStream rlp = results.Data.AsRlpStream(); rlp.ReadSequenceLength(); int version = rlp.DecodeInt(); rlp.ReadSequenceLength(); ReadOnlySpan <byte> sourceAddress = rlp.DecodeByteArraySpan(); // TODO: please note that we decode only one field for port and if the UDP is different from TCP then // our discovery messages will not be routed correctly (the fix will not be part of this commit) rlp.DecodeInt(); // UDP port int tcpPort = rlp.DecodeInt(); // we assume here that UDP and TCP port are same IPEndPoint source = GetAddress(sourceAddress, tcpPort); rlp.ReadSequenceLength(); ReadOnlySpan <byte> destinationAddress = rlp.DecodeByteArraySpan(); IPEndPoint destination = GetAddress(destinationAddress, rlp.DecodeInt()); rlp.DecodeInt(); // UDP port long expireTime = rlp.DecodeLong(); PingMsg msg = new(results.FarPublicKey, expireTime, source, destination, results.Mdc); msg.Version = version; if (version == 4) { if (!rlp.HasBeenRead) { long enrSequence = rlp.DecodeLong(); msg.EnrSequence = enrSequence; } } else { // what do we do when receive version 5? } return(msg); }
public static ContractCodesMessage Deserialize(RlpStream rlpStream) { ContractCodesMessage contractCodesMessage = new ContractCodesMessage(); rlpStream.ReadSequenceLength(); contractCodesMessage.RequestId = rlpStream.DecodeLong(); contractCodesMessage.BufferValue = rlpStream.DecodeInt(); contractCodesMessage.Codes = rlpStream.DecodeArray(stream => stream.DecodeByteArray()); return(contractCodesMessage); }
public DataStreamDisabledMessage Deserialize(byte[] bytes) { RlpStream context = bytes.AsRlpStream(); context.ReadSequenceLength(); Keccak?depositId = context.DecodeKeccak(); string client = context.DecodeString(); return(new DataStreamDisabledMessage(depositId, client)); }
private static BlockBodiesMessage Deserialize(RlpStream rlpStream) { BlockBodiesMessage blockBodiesMessage = new BlockBodiesMessage(); rlpStream.ReadSequenceLength(); blockBodiesMessage.RequestId = rlpStream.DecodeLong(); blockBodiesMessage.BufferValue = rlpStream.DecodeInt(); blockBodiesMessage.EthMessage = Eth.V62.BlockBodiesMessageSerializer.Deserialize(rlpStream); return(blockBodiesMessage); }
public AckEip8Message Deserialize(byte[] bytes) { RlpStream rlpStream = bytes.AsRlpStream(); AckEip8Message authEip8Message = new AckEip8Message(); rlpStream.ReadSequenceLength(); authEip8Message.EphemeralPublicKey = new PublicKey(rlpStream.DecodeByteArray()); authEip8Message.Nonce = rlpStream.DecodeByteArray(); return(authEip8Message); }
public DataAvailabilityMessage Deserialize(byte[] bytes) { RlpStream context = bytes.AsRlpStream(); context.ReadSequenceLength(); Keccak? depositId = context.DecodeKeccak(); DataAvailability reason = (DataAvailability)context.DecodeInt(); return(new DataAvailabilityMessage(depositId, reason)); }
public AddCapabilityMessage Deserialize(byte[] msgBytes) { RlpStream context = msgBytes.AsRlpStream(); context.ReadSequenceLength(); string protocolCode = context.DecodeString(); byte version = context.DecodeByte(); return(new AddCapabilityMessage(new Capability(protocolCode, version))); }
public RequestDepositApprovalMessage Deserialize(byte[] bytes) { RlpStream context = bytes.AsRlpStream(); context.ReadSequenceLength(); Keccak? dataAssetId = context.DecodeKeccak(); Address?consumer = context.DecodeAddress(); string kyc = context.DecodeString(); return(new RequestDepositApprovalMessage(dataAssetId, consumer, kyc)); }
public PongMsg Deserialize(byte[] msgBytes) { (PublicKey FarPublicKey, byte[] Mdc, byte[] Data)results = PrepareForDeserialization(msgBytes); RlpStream rlp = results.Data.AsRlpStream(); rlp.ReadSequenceLength(); rlp.ReadSequenceLength(); // GetAddress(rlp.DecodeByteArray(), rlp.DecodeInt()); rlp.DecodeByteArraySpan(); rlp.DecodeInt(); // UDP port (we ignore and take it from Netty) rlp.DecodeInt(); // TCP port byte[] token = rlp.DecodeByteArray(); long expirationTime = rlp.DecodeLong(); PongMsg msg = new(results.FarPublicKey, expirationTime, token); return(msg); }
public Consumer Decode(RlpStream rlpStream, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { _ = rlpStream.ReadSequenceLength(); var depositId = rlpStream.DecodeKeccak(); var verificationTimestamp = rlpStream.DecodeUInt(); var dataRequest = Nethermind.Serialization.Rlp.Rlp.Decode <DataRequest>(rlpStream); var dataAsset = Nethermind.Serialization.Rlp.Rlp.Decode <DataAsset>(rlpStream); var hasAvailableUnits = rlpStream.DecodeBool(); return(new Consumer(depositId, verificationTimestamp, dataRequest, dataAsset, hasAvailableUnits)); }
private ParityAccountStateChange DecodeAccountStateChange(RlpStream rlpStream) { rlpStream.ReadSequenceLength(); ParityAccountStateChange change = new ParityAccountStateChange(); change.Balance = DecodeChange(rlpStream); change.Code = DecodeByteChange(rlpStream); change.Nonce = DecodeChange(rlpStream); change.Storage = DecodeStorageChange(rlpStream); return(change); }
public Deposit Decode(RlpStream rlpStream, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { rlpStream.ReadSequenceLength(); Keccak id = rlpStream.DecodeKeccak(); uint units = rlpStream.DecodeUInt(); uint expiryTime = rlpStream.DecodeUInt(); UInt256 value = rlpStream.DecodeUInt256(); return(new Deposit(id, units, expiryTime, value)); }
private PathWithStorageSlot DecodeSlot(RlpStream stream) { stream.ReadSequenceLength(); Keccak path = stream.DecodeKeccak(); byte[] value = stream.DecodeByteArray(); PathWithStorageSlot data = new(path, value); return(data); }
public DataDeliveryReceiptRequest Decode(RlpStream rlpStream, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { rlpStream.ReadSequenceLength(); uint number = rlpStream.DecodeUInt(); Keccak depositId = rlpStream.DecodeKeccak(); UnitsRange unitsRange = Serialization.Rlp.Rlp.Decode <UnitsRange>(rlpStream); bool isSettlement = rlpStream.DecodeBool(); var receipts = Serialization.Rlp.Rlp.DecodeArray <DataDeliveryReceiptToMerge>(rlpStream); return(new DataDeliveryReceiptRequest(number, depositId, unitsRange, isSettlement, receipts)); }
public ReceiptsMessage Deserialize(RlpStream rlpStream) { ReceiptsMessage receiptsMessage = new ReceiptsMessage(); Eth.V63.ReceiptsMessageSerializer ethSerializer = new Eth.V63.ReceiptsMessageSerializer(_specProvider); rlpStream.ReadSequenceLength(); receiptsMessage.RequestId = rlpStream.DecodeLong(); receiptsMessage.BufferValue = rlpStream.DecodeInt(); receiptsMessage.EthMessage = ethSerializer.Deserialize(rlpStream); return(receiptsMessage); }
private static StatusMessage Deserialize(RlpStream rlpStream) { StatusMessage statusMessage = new StatusMessage(); rlpStream.ReadSequenceLength(); statusMessage.ProtocolVersion = rlpStream.DecodeByte(); statusMessage.ChainId = rlpStream.DecodeUInt256(); statusMessage.TotalDifficulty = rlpStream.DecodeUInt256(); statusMessage.BestHash = rlpStream.DecodeKeccak(); statusMessage.GenesisHash = rlpStream.DecodeKeccak(); return(statusMessage); }
private static HiMessage Deserialize(RlpStream rlpStream) { rlpStream.ReadSequenceLength(); var protocolVersion = rlpStream.DecodeByte(); var providerAddress = rlpStream.DecodeAddress(); var consumerAddress = rlpStream.DecodeAddress(); var nodeId = new PublicKey(rlpStream.DecodeByteArray()); var signature = SignatureDecoder.DecodeSignature(rlpStream); return(new HiMessage(protocolVersion, providerAddress, consumerAddress, nodeId, signature)); }
protected override GetByteCodesMessage Deserialize(RlpStream rlpStream) { GetByteCodesMessage message = new (); rlpStream.ReadSequenceLength(); message.RequestId = rlpStream.DecodeLong(); message.Hashes = rlpStream.DecodeArray(_ => rlpStream.DecodeKeccak()); message.Bytes = rlpStream.DecodeLong(); return(message); }
private static StatusMessage Deserialize(RlpStream rlpStream) { StatusMessage statusMessage = new StatusMessage(); rlpStream.ReadSequenceLength(); statusMessage.ProtocolVersion = rlpStream.DecodeByte(); statusMessage.ChainId = rlpStream.DecodeUInt256(); statusMessage.TotalDifficulty = rlpStream.DecodeUInt256(); statusMessage.BestHash = rlpStream.DecodeKeccak(); statusMessage.GenesisHash = rlpStream.DecodeKeccak(); if (rlpStream.Position < rlpStream.Length) { rlpStream.ReadSequenceLength(); byte[] forkHash = rlpStream.DecodeByteArray(); long next = (long)rlpStream.DecodeUlong(); ForkId forkId = new(forkHash, next); statusMessage.ForkId = forkId; } return(statusMessage); }
public static T[] DecodeArray <T>(this IRlpStreamDecoder <T> decoder, RlpStream rlpStream, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { int checkPosition = rlpStream.ReadSequenceLength() + rlpStream.Position; T[] result = new T[rlpStream.ReadNumberOfItemsRemaining(checkPosition)]; for (int i = 0; i < result.Length; i++) { result[i] = decoder.Decode(rlpStream, rlpBehaviors); } return(result); }
public EnrRequestMsg Deserialize(byte[] msgBytes) { (PublicKey FarPublicKey, byte[] Mdc, byte[] Data)results = PrepareForDeserialization(msgBytes); RlpStream rlpStream = results.Data.AsRlpStream(); rlpStream.ReadSequenceLength(); long expirationTime = rlpStream.DecodeLong(); EnrRequestMsg msg = new (results.FarPublicKey, expirationTime); return(msg); }
protected override GetAccountRangeMessage Deserialize(RlpStream rlpStream) { GetAccountRangeMessage message = new (); rlpStream.ReadSequenceLength(); message.RequestId = rlpStream.DecodeLong(); message.AccountRange = new(rlpStream.DecodeKeccak(), rlpStream.DecodeKeccak(), rlpStream.DecodeKeccak()); message.ResponseBytes = rlpStream.DecodeLong(); return(message); }
public EnableDataStreamMessage Deserialize(byte[] bytes) { RlpStream context = bytes.AsRlpStream(); context.ReadSequenceLength(); Keccak?depositId = context.DecodeKeccak(); string client = context.DecodeString(); string?[] args = context.DecodeArray(c => c.DecodeString()); return(new EnableDataStreamMessage(depositId, client, args)); }