public ConsumerSession Decode(RlpStream rlpStream, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { rlpStream.ReadSequenceLength(); Keccak id = rlpStream.DecodeKeccak(); Keccak depositId = rlpStream.DecodeKeccak(); Keccak dataAssetId = rlpStream.DecodeKeccak(); Address consumerAddress = rlpStream.DecodeAddress(); PublicKey consumerNodeId = new PublicKey(rlpStream.DecodeByteArray()); Address providerAddress = rlpStream.DecodeAddress(); PublicKey providerNodeId = new PublicKey(rlpStream.DecodeByteArray()); SessionState state = (SessionState)rlpStream.DecodeInt(); uint startUnitsFromProvider = rlpStream.DecodeUInt(); uint startUnitsFromConsumer = rlpStream.DecodeUInt(); ulong startTimestamp = rlpStream.DecodeUlong(); ulong finishTimestamp = rlpStream.DecodeUlong(); uint consumedUnits = rlpStream.DecodeUInt(); uint unpaidUnits = rlpStream.DecodeUInt(); uint paidUnits = rlpStream.DecodeUInt(); uint settledUnits = rlpStream.DecodeUInt(); uint consumedUnitsFromProvider = rlpStream.DecodeUInt(); DataAvailability dataAvailability = (DataAvailability)rlpStream.DecodeInt(); return(new ConsumerSession(id, depositId, dataAssetId, consumerAddress, consumerNodeId, providerAddress, providerNodeId, state, startUnitsFromProvider, startUnitsFromConsumer, startTimestamp, finishTimestamp, consumedUnits, unpaidUnits, paidUnits, settledUnits, consumedUnitsFromProvider, dataAvailability)); }
public PaymentClaim Decode(RlpStream rlpStream, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { _ = rlpStream.ReadSequenceLength(); var id = rlpStream.DecodeKeccak(); var depositId = rlpStream.DecodeKeccak(); var assetId = rlpStream.DecodeKeccak(); var assetName = rlpStream.DecodeString(); var units = rlpStream.DecodeUInt(); var claimedUnits = rlpStream.DecodeUInt(); var unitsRange = Nethermind.Serialization.Rlp.Rlp.Decode <UnitsRange>(rlpStream); var value = rlpStream.DecodeUInt256(); var claimedValue = rlpStream.DecodeUInt256(); var expiryTime = rlpStream.DecodeUInt(); var pepper = rlpStream.DecodeByteArray(); var provider = rlpStream.DecodeAddress(); var consumer = rlpStream.DecodeAddress(); var transactions = Rlp.DecodeArray <TransactionInfo>(rlpStream); var transactionCost = rlpStream.DecodeUInt256(); var timestamp = rlpStream.DecodeUlong(); var status = (PaymentClaimStatus)rlpStream.DecodeInt(); var signature = SignatureDecoder.DecodeSignature(rlpStream); var paymentClaim = new PaymentClaim(id, depositId, assetId, assetName, units, claimedUnits, unitsRange, value, claimedValue, expiryTime, pepper, provider, consumer, signature, timestamp, transactions, status); if (status == PaymentClaimStatus.Claimed) { paymentClaim.SetTransactionCost(transactionCost); } return(paymentClaim); }
public Session Decode(RlpStream rlpStream, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { var sequenceLength = rlpStream.ReadSequenceLength(); if (sequenceLength == 0) { return(null); } var id = rlpStream.DecodeKeccak(); var depositId = rlpStream.DecodeKeccak(); var dataAssetId = rlpStream.DecodeKeccak(); var consumerAddress = rlpStream.DecodeAddress(); var consumerNodeId = new PublicKey(rlpStream.DecodeByteArray()); var providerAddress = rlpStream.DecodeAddress(); var providerNodeId = new PublicKey(rlpStream.DecodeByteArray()); var state = (SessionState)rlpStream.DecodeInt(); var startUnitsFromProvider = rlpStream.DecodeUInt(); var startUnitsFromConsumer = rlpStream.DecodeUInt(); var startTimestamp = rlpStream.DecodeUlong(); var finishTimestamp = rlpStream.DecodeUlong(); var consumedUnits = rlpStream.DecodeUInt(); var unpaidUnits = rlpStream.DecodeUInt(); var paidUnits = rlpStream.DecodeUInt(); var settledUnits = rlpStream.DecodeUInt(); return(new Session(id, depositId, dataAssetId, consumerAddress, consumerNodeId, providerAddress, providerNodeId, state, startUnitsFromProvider, startUnitsFromConsumer, startTimestamp, finishTimestamp, consumedUnits, unpaidUnits, paidUnits, settledUnits)); }
private static StatusMessage Deserialize(RlpStream rlpStream) { StatusMessage statusMessage = new StatusMessage(); (int prefixLength, int contentLength) = rlpStream.PeekPrefixAndContentLength(); var totalLength = contentLength; rlpStream.Position += prefixLength; var readLength = prefixLength; while (totalLength > readLength) { (prefixLength, contentLength) = rlpStream.PeekPrefixAndContentLength(); readLength += prefixLength + contentLength; rlpStream.Position += prefixLength; string key = rlpStream.DecodeString(); switch (key) { case StatusMessage.KeyNames.ProtocolVersion: statusMessage.ProtocolVersion = rlpStream.DecodeByte(); break; case StatusMessage.KeyNames.ChainId: statusMessage.ChainId = rlpStream.DecodeUInt256(); break; case StatusMessage.KeyNames.TotalDifficulty: statusMessage.TotalDifficulty = rlpStream.DecodeUInt256(); break; case StatusMessage.KeyNames.BestHash: statusMessage.BestHash = rlpStream.DecodeKeccak(); break; case StatusMessage.KeyNames.HeadBlockNo: statusMessage.HeadBlockNo = rlpStream.DecodeLong(); break; case StatusMessage.KeyNames.GenesisHash: statusMessage.GenesisHash = rlpStream.DecodeKeccak(); break; case StatusMessage.KeyNames.AnnounceType: statusMessage.AnnounceType = rlpStream.DecodeByte(); break; default: // Ignore unknown keys - forwards compatibility rlpStream.Position = readLength; break; } } return(statusMessage); }
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); }
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 DataDeliveryReceiptDetails Decode(RlpStream rlpStream, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { rlpStream.ReadSequenceLength(); Keccak id = rlpStream.DecodeKeccak(); Keccak sessionId = rlpStream.DecodeKeccak(); Keccak dataAssetId = rlpStream.DecodeKeccak(); PublicKey consumerNodeId = new PublicKey(rlpStream.DecodeByteArray()); DataDeliveryReceiptRequest request = Serialization.Rlp.Rlp.Decode <DataDeliveryReceiptRequest>(rlpStream); DataDeliveryReceipt receipt = Serialization.Rlp.Rlp.Decode <DataDeliveryReceipt>(rlpStream); ulong timestamp = rlpStream.DecodeUlong(); bool isClaimed = rlpStream.DecodeBool(); return(new DataDeliveryReceiptDetails(id, sessionId, dataAssetId, consumerNodeId, request, receipt, timestamp, isClaimed)); }
public DepositApproval Decode(RlpStream rlpStream, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { rlpStream.ReadSequenceLength(); Keccak id = rlpStream.DecodeKeccak(); Keccak assetId = rlpStream.DecodeKeccak(); string assetName = rlpStream.DecodeString(); string kyc = rlpStream.DecodeString(); Address consumer = rlpStream.DecodeAddress(); Address provider = rlpStream.DecodeAddress(); ulong timestamp = rlpStream.DecodeUlong(); DepositApprovalState state = (DepositApprovalState)rlpStream.DecodeInt(); return(new DepositApproval(id, assetId, assetName, kyc, consumer, provider, timestamp, state)); }
public PendingValidators Decode(RlpStream rlpStream, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { if (rlpStream.IsNextItemNull()) { rlpStream.ReadByte(); return(null); } var sequenceLength = rlpStream.ReadSequenceLength(); var pendingValidatorsCheck = rlpStream.Position + sequenceLength; var blockNumber = rlpStream.DecodeLong(); var blockHash = rlpStream.DecodeKeccak(); var addressSequenceLength = rlpStream.ReadSequenceLength(); var addressCheck = rlpStream.Position + addressSequenceLength; List <Address> addresses = new List <Address>(); while (rlpStream.Position < addressCheck) { addresses.Add(rlpStream.DecodeAddress()); } rlpStream.Check(addressCheck); var result = new PendingValidators(blockNumber, blockHash, addresses.ToArray()) { AreFinalized = rlpStream.DecodeBool() }; rlpStream.Check(pendingValidatorsCheck); return(result); }
public DataAsset Decode(RlpStream rlpStream, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { var sequenceLength = rlpStream.ReadSequenceLength(); if (sequenceLength == 0) { return(null); } var id = rlpStream.DecodeKeccak(); var name = rlpStream.DecodeString(); var description = rlpStream.DecodeString(); var unitPrice = rlpStream.DecodeUInt256(); var unitType = (DataAssetUnitType)rlpStream.DecodeInt(); var minUnits = rlpStream.DecodeUInt(); var maxUnits = rlpStream.DecodeUInt(); var rules = Nethermind.Core.Encoding.Rlp.Decode <DataAssetRules>(rlpStream); var provider = Nethermind.Core.Encoding.Rlp.Decode <DataAssetProvider>(rlpStream); var file = rlpStream.DecodeString(); var queryType = (QueryType)rlpStream.DecodeInt(); var state = (DataAssetState)rlpStream.DecodeInt(); var termsAndConditions = rlpStream.DecodeString(); var kycRequired = rlpStream.DecodeBool(); var plugin = rlpStream.DecodeString(); return(new DataAsset(id, name, description, unitPrice, unitType, minUnits, maxUnits, rules, provider, file, queryType, state, termsAndConditions, kycRequired, plugin)); }
public DataAsset Decode(RlpStream rlpStream, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { try { rlpStream.ReadSequenceLength(); Keccak id = rlpStream.DecodeKeccak(); string name = rlpStream.DecodeString(); string description = rlpStream.DecodeString(); UInt256 unitPrice = rlpStream.DecodeUInt256(); DataAssetUnitType unitType = (DataAssetUnitType)rlpStream.DecodeInt(); uint minUnits = rlpStream.DecodeUInt(); uint maxUnits = rlpStream.DecodeUInt(); DataAssetRules rules = Serialization.Rlp.Rlp.Decode <DataAssetRules>(rlpStream); DataAssetProvider provider = Serialization.Rlp.Rlp.Decode <DataAssetProvider>(rlpStream); string file = rlpStream.DecodeString(); QueryType queryType = (QueryType)rlpStream.DecodeInt(); DataAssetState state = (DataAssetState)rlpStream.DecodeInt(); string termsAndConditions = rlpStream.DecodeString(); bool kycRequired = rlpStream.DecodeBool(); string plugin = rlpStream.DecodeString(); return(new DataAsset(id, name, description, unitPrice, unitType, minUnits, maxUnits, rules, provider, file, queryType, state, termsAndConditions, kycRequired, plugin)); } catch (Exception e) { throw new RlpException($"{nameof(DataAsset)} could not be deserialized", e); } }
protected override GetStorageRangeMessage Deserialize(RlpStream rlpStream) { GetStorageRangeMessage message = new (); rlpStream.ReadSequenceLength(); message.RequestId = rlpStream.DecodeLong(); message.StoragetRange = new(); message.StoragetRange.RootHash = rlpStream.DecodeKeccak(); message.StoragetRange.Accounts = rlpStream.DecodeArray(DecodePathWithRlpData); message.StoragetRange.StartingHash = rlpStream.DecodeKeccak(); message.StoragetRange.LimitHash = rlpStream.DecodeKeccak(); message.ResponseBytes = rlpStream.DecodeLong(); return(message); }
public EthRequest Decode(RlpStream rlpStream, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { var sequenceLength = rlpStream.ReadSequenceLength(); if (sequenceLength == 0) { return(null); } var id = rlpStream.DecodeKeccak(); var host = rlpStream.DecodeString(); var address = rlpStream.DecodeAddress(); var value = rlpStream.DecodeUInt256(); var requestedAt = DateTimeOffset.FromUnixTimeSeconds(rlpStream.DecodeLong()).UtcDateTime; var transactionHash = rlpStream.DecodeKeccak(); return(new EthRequest(id, host, address, value, requestedAt, transactionHash)); }
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); }
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 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 DataStreamDisabledMessage Deserialize(byte[] bytes) { RlpStream context = bytes.AsRlpStream(); context.ReadSequenceLength(); Keccak?depositId = context.DecodeKeccak(); string client = context.DecodeString(); return(new DataStreamDisabledMessage(depositId, client)); }
public EthRequest Decode(RlpStream rlpStream, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { try { rlpStream.ReadSequenceLength(); Keccak id = rlpStream.DecodeKeccak(); string host = rlpStream.DecodeString(); Address address = rlpStream.DecodeAddress(); UInt256 value = rlpStream.DecodeUInt256(); DateTime requestedAt = DateTimeOffset.FromUnixTimeSeconds(rlpStream.DecodeLong()).UtcDateTime; Keccak transactionHash = rlpStream.DecodeKeccak(); return(new EthRequest(id, host, address, value, requestedAt, transactionHash)); } catch (Exception e) { throw new RlpException($"{nameof(EthRequest)} cannot be deserialized from", e); } }
private PathWithStorageSlot DecodeSlot(RlpStream stream) { stream.ReadSequenceLength(); Keccak path = stream.DecodeKeccak(); byte[] value = stream.DecodeByteArray(); PathWithStorageSlot data = new(path, value); return(data); }
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)); }
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)); }
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)); }
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 AnnounceMessage Deserialize(RlpStream rlpStream) { AnnounceMessage announceMessage = new(); rlpStream.ReadSequenceLength(); announceMessage.HeadHash = rlpStream.DecodeKeccak(); announceMessage.HeadBlockNo = rlpStream.DecodeLong(); announceMessage.TotalDifficulty = rlpStream.DecodeUInt256(); announceMessage.ReorgDepth = rlpStream.DecodeLong(); rlpStream.ReadSequenceLength(); return(announceMessage); }
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 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 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)); }
public DepositApproval Decode(RlpStream rlpStream, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { var sequenceLength = rlpStream.ReadSequenceLength(); if (sequenceLength == 0) { return(null); } var id = rlpStream.DecodeKeccak(); var assetId = rlpStream.DecodeKeccak(); var assetName = rlpStream.DecodeString(); var kyc = rlpStream.DecodeString(); var consumer = rlpStream.DecodeAddress(); var provider = rlpStream.DecodeAddress(); var timestamp = rlpStream.DecodeUlong(); var state = (DepositApprovalState)rlpStream.DecodeInt(); return(new DepositApproval(id, assetId, assetName, kyc, consumer, provider, timestamp, state)); }
public DataDeliveryReceiptDetails Decode(RlpStream rlpStream, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { var sequenceLength = rlpStream.ReadSequenceLength(); if (sequenceLength == 0) { return(null); } var id = rlpStream.DecodeKeccak(); var sessionId = rlpStream.DecodeKeccak(); var dataAssetId = rlpStream.DecodeKeccak(); var consumerNodeId = new PublicKey(rlpStream.DecodeByteArray()); var request = Nethermind.Core.Encoding.Rlp.Decode <DataDeliveryReceiptRequest>(rlpStream); var receipt = Nethermind.Core.Encoding.Rlp.Decode <DataDeliveryReceipt>(rlpStream); var timestamp = rlpStream.DecodeUlong(); var isClaimed = rlpStream.DecodeBool(); return(new DataDeliveryReceiptDetails(id, sessionId, dataAssetId, consumerNodeId, request, receipt, timestamp, isClaimed)); }
public DataRequest Decode(RlpStream rlpStream, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { rlpStream.ReadSequenceLength(); Keccak assetId = rlpStream.DecodeKeccak(); uint units = rlpStream.DecodeUInt(); UInt256 value = rlpStream.DecodeUInt256(); uint expiryTime = rlpStream.DecodeUInt(); var salt = rlpStream.DecodeByteArray(); Address provider = rlpStream.DecodeAddress(); Address consumer = rlpStream.DecodeAddress(); Signature signature = SignatureDecoder.DecodeSignature(rlpStream); return(new DataRequest(assetId, units, value, expiryTime, salt, provider, consumer, signature)); }