public NdmConfig Decode(RlpStream rlpStream, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { var sequenceLength = rlpStream.ReadSequenceLength(); if (sequenceLength == 0) { return(null); } var enabled = rlpStream.DecodeBool(); var id = rlpStream.DecodeString(); var initializerName = rlpStream.DecodeString(); var storeConfigInDatabase = rlpStream.DecodeBool(); var verifyP2PSignature = rlpStream.DecodeBool(); var persistence = rlpStream.DecodeString(); var faucetEnabled = rlpStream.DecodeBool(); var faucetAddress = rlpStream.DecodeString(); var faucetHost = rlpStream.DecodeString(); var faucetWeiRequestMaxValue = rlpStream.DecodeUInt256(); var faucetEthDailyRequestsTotalValue = rlpStream.DecodeUInt256(); var consumerAddress = rlpStream.DecodeString(); var contractAddress = rlpStream.DecodeString(); var providerName = rlpStream.DecodeString(); var providerAddress = rlpStream.DecodeString(); var providerColdWalletAddress = rlpStream.DecodeString(); var receiptRequestThreshold = rlpStream.DecodeUInt256(); var receiptsMergeThreshold = rlpStream.DecodeUInt256(); var paymentClaimThreshold = rlpStream.DecodeUInt256(); var blockConfirmations = rlpStream.DecodeUInt(); var filesPath = rlpStream.DecodeString(); var fileMaxSize = rlpStream.DecodeUlong(); var pluginsPath = rlpStream.DecodeString(); return(new NdmConfig { Enabled = enabled, Id = id, InitializerName = initializerName, StoreConfigInDatabase = storeConfigInDatabase, VerifyP2PSignature = verifyP2PSignature, Persistence = persistence, FaucetEnabled = faucetEnabled, FaucetAddress = faucetAddress, FaucetHost = faucetHost, FaucetWeiRequestMaxValue = faucetWeiRequestMaxValue, FaucetEthDailyRequestsTotalValue = faucetEthDailyRequestsTotalValue, ConsumerAddress = consumerAddress, ContractAddress = contractAddress, ProviderName = providerName, ProviderAddress = providerAddress, ProviderColdWalletAddress = providerColdWalletAddress, ReceiptRequestThreshold = receiptRequestThreshold, ReceiptsMergeThreshold = receiptsMergeThreshold, PaymentClaimThreshold = paymentClaimThreshold, BlockConfirmations = blockConfirmations, FilesPath = filesPath, FileMaxSize = fileMaxSize, PluginsPath = pluginsPath }); }
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); } }
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 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 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 DepositDetails Decode(RlpStream rlpStream, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { rlpStream.ReadSequenceLength(); Deposit deposit = Serialization.Rlp.Rlp.Decode <Deposit>(rlpStream); DataAsset dataAsset = Serialization.Rlp.Rlp.Decode <DataAsset>(rlpStream); Address consumer = rlpStream.DecodeAddress(); var pepper = rlpStream.DecodeByteArray(); uint timestamp = rlpStream.DecodeUInt(); var transactions = Serialization.Rlp.Rlp.DecodeArray <TransactionInfo>(rlpStream); uint confirmationTimestamp = rlpStream.DecodeUInt(); bool rejected = rlpStream.DecodeBool(); bool cancelled = rlpStream.DecodeBool(); EarlyRefundTicket earlyRefundTicket = Serialization.Rlp.Rlp.Decode <EarlyRefundTicket>(rlpStream); var claimedRefundTransactions = Serialization.Rlp.Rlp.DecodeArray <TransactionInfo>(rlpStream); bool refundClaimed = rlpStream.DecodeBool(); bool refundCancelled = rlpStream.DecodeBool(); string kyc = rlpStream.DecodeString(); uint confirmations = rlpStream.DecodeUInt(); uint requiredConfirmations = rlpStream.DecodeUInt(); return(new DepositDetails(deposit, dataAsset, consumer, pepper, timestamp, transactions, confirmationTimestamp, rejected, cancelled, earlyRefundTicket, claimedRefundTransactions, refundClaimed, refundCancelled, kyc, confirmations, requiredConfirmations)); }
private List <Vote> DecodeVotes(RlpStream rlpStream) { rlpStream.ReadSequenceLength(); List <Vote> votes = new List <Vote>(); int length = rlpStream.DecodeInt(); for (int i = 0; i < length; i++) { Address signer = rlpStream.DecodeAddress(); long block = (long)rlpStream.DecodeUInt256(); Address address = rlpStream.DecodeAddress(); bool authorize = rlpStream.DecodeBool(); Vote vote = new Vote(signer, block, address, authorize); votes.Add(vote); } return(votes); }
private Dictionary <Address, Tally> DecodeTally(RlpStream rlpStream) { rlpStream.ReadSequenceLength(); Dictionary <Address, Tally> tally = new Dictionary <Address, Tally>(); int length = rlpStream.DecodeInt(); for (int i = 0; i < length; i++) { Address address = rlpStream.DecodeAddress(); int votes = rlpStream.DecodeInt(); bool authorize = rlpStream.DecodeBool(); Tally tallyItem = new Tally(authorize); tallyItem.Votes = votes; tally[address] = tallyItem; } return(tally); }
public DataDeliveryReceiptRequest Decode(RlpStream rlpStream, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { var sequenceLength = rlpStream.ReadSequenceLength(); if (sequenceLength == 0) { return(null); } var number = rlpStream.DecodeUInt(); var depositId = rlpStream.DecodeKeccak(); var unitsRange = Nethermind.Core.Encoding.Rlp.Decode <UnitsRange>(rlpStream); var isSettlement = rlpStream.DecodeBool(); var receipts = Nethermind.Core.Encoding.Rlp.DecodeArray <DataDeliveryReceiptToMerge>(rlpStream); return(new DataDeliveryReceiptRequest(number, depositId, unitsRange, isSettlement, receipts)); }
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 DepositDetails Decode(RlpStream rlpStream, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { try { var sequenceLength = rlpStream.ReadSequenceLength(); if (sequenceLength == 0) { return(null); } var deposit = Nethermind.Core.Encoding.Rlp.Decode <Deposit>(rlpStream); var dataAsset = Nethermind.Core.Encoding.Rlp.Decode <DataAsset>(rlpStream); var consumer = rlpStream.DecodeAddress(); var pepper = rlpStream.DecodeByteArray(); var timestamp = rlpStream.DecodeUInt(); var transaction = Nethermind.Core.Encoding.Rlp.Decode <TransactionInfo>(rlpStream); var confirmationTimestamp = rlpStream.DecodeUInt(); var rejected = rlpStream.DecodeBool(); var earlyRefundTicket = Nethermind.Core.Encoding.Rlp.Decode <EarlyRefundTicket>(rlpStream); var claimedRefundTransaction = Nethermind.Core.Encoding.Rlp.Decode <TransactionInfo>(rlpStream); var refundClaimed = rlpStream.DecodeBool(); var kyc = rlpStream.DecodeString(); var confirmations = rlpStream.DecodeUInt(); var requiredConfirmations = rlpStream.DecodeUInt(); return(new DepositDetails(deposit, dataAsset, consumer, pepper, timestamp, transaction, confirmationTimestamp, rejected, earlyRefundTicket, claimedRefundTransaction, refundClaimed, kyc, confirmations, requiredConfirmations)); } catch (Exception) { rlpStream.Position = 0; var sequenceLength = rlpStream.ReadSequenceLength(); if (sequenceLength == 0) { return(null); } var deposit = Nethermind.Core.Encoding.Rlp.Decode <Deposit>(rlpStream); var dataAsset = Nethermind.Core.Encoding.Rlp.Decode <DataAsset>(rlpStream); var consumer = rlpStream.DecodeAddress(); var pepper = rlpStream.DecodeByteArray(); var transaction = Nethermind.Core.Encoding.Rlp.Decode <TransactionInfo>(rlpStream); var confirmationTimestamp = rlpStream.DecodeUInt(); var rejected = rlpStream.DecodeBool(); var earlyRefundTicket = Nethermind.Core.Encoding.Rlp.Decode <EarlyRefundTicket>(rlpStream); var claimedRefundTransaction = Nethermind.Core.Encoding.Rlp.Decode <TransactionInfo>(rlpStream); var refundClaimed = rlpStream.DecodeBool(); var kyc = rlpStream.DecodeString(); var confirmations = rlpStream.DecodeUInt(); var requiredConfirmations = rlpStream.DecodeUInt(); uint timestamp = 0; if (rlpStream.Position != rlpStream.Data.Length) { timestamp = rlpStream.DecodeUInt(); } return(new DepositDetails(deposit, dataAsset, consumer, pepper, timestamp, transaction, confirmationTimestamp, rejected, earlyRefundTicket, claimedRefundTransaction, refundClaimed, kyc, confirmations, requiredConfirmations)); } }
public NdmConfig Decode(RlpStream rlpStream, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { try { rlpStream.ReadSequenceLength(); bool enabled = rlpStream.DecodeBool(); string id = rlpStream.DecodeString(); string initializerName = rlpStream.DecodeString(); bool storeConfigInDatabase = rlpStream.DecodeBool(); bool verifyP2PSignature = rlpStream.DecodeBool(); string persistence = rlpStream.DecodeString(); bool faucetEnabled = rlpStream.DecodeBool(); string faucetAddress = rlpStream.DecodeString(); string faucetHost = rlpStream.DecodeString(); UInt256 faucetWeiRequestMaxValue = rlpStream.DecodeUInt256(); UInt256 faucetEthDailyRequestsTotalValue = rlpStream.DecodeUInt256(); string consumerAddress = rlpStream.DecodeString(); string contractAddress = rlpStream.DecodeString(); string providerName = rlpStream.DecodeString(); string providerAddress = rlpStream.DecodeString(); string providerColdWalletAddress = rlpStream.DecodeString(); UInt256 receiptRequestThreshold = rlpStream.DecodeUInt256(); UInt256 receiptsMergeThreshold = rlpStream.DecodeUInt256(); UInt256 paymentClaimThreshold = rlpStream.DecodeUInt256(); uint blockConfirmations = rlpStream.DecodeUInt(); string filesPath = rlpStream.DecodeString(); ulong fileMaxSize = rlpStream.DecodeUlong(); string pluginsPath = rlpStream.DecodeString(); string databasePath = rlpStream.DecodeString(); bool proxyEnabled = rlpStream.DecodeBool(); var jsonRpcUrlProxies = rlpStream.DecodeArray(c => c.DecodeString()); string gasPriceType = rlpStream.DecodeString(); UInt256 gasPrice = rlpStream.DecodeUInt256(); uint cancelTransactionGasPricePercentageMultiplier = rlpStream.DecodeUInt(); bool jsonRpcDataChannelEnabled = rlpStream.DecodeBool(); UInt256 refundGasPrice = rlpStream.DecodeUInt256(); return(new NdmConfig { Enabled = enabled, Id = id, InitializerName = initializerName, StoreConfigInDatabase = storeConfigInDatabase, VerifyP2PSignature = verifyP2PSignature, Persistence = persistence, FaucetEnabled = faucetEnabled, FaucetAddress = faucetAddress == string.Empty ? null : faucetAddress, FaucetHost = faucetHost == string.Empty ? null : faucetHost, FaucetWeiRequestMaxValue = faucetWeiRequestMaxValue, FaucetEthDailyRequestsTotalValue = faucetEthDailyRequestsTotalValue, ConsumerAddress = consumerAddress == string.Empty ? null : consumerAddress, ContractAddress = contractAddress == string.Empty ? null : contractAddress, ProviderName = providerName, ProviderAddress = providerAddress == string.Empty ? null : providerAddress, ProviderColdWalletAddress = providerColdWalletAddress == string.Empty ? null : providerColdWalletAddress, ReceiptRequestThreshold = receiptRequestThreshold, ReceiptsMergeThreshold = receiptsMergeThreshold, PaymentClaimThreshold = paymentClaimThreshold, BlockConfirmations = blockConfirmations, FilesPath = filesPath, FileMaxSize = fileMaxSize, PluginsPath = pluginsPath, DatabasePath = databasePath, ProxyEnabled = proxyEnabled, JsonRpcUrlProxies = jsonRpcUrlProxies !, GasPriceType = gasPriceType, GasPrice = gasPrice, CancelTransactionGasPricePercentageMultiplier = cancelTransactionGasPricePercentageMultiplier, JsonRpcDataChannelEnabled = jsonRpcDataChannelEnabled, RefundGasPrice = refundGasPrice }); }
public NdmConfig Decode(RlpStream rlpStream, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { var sequenceLength = rlpStream.ReadSequenceLength(); if (sequenceLength == 0) { return(null); } var enabled = rlpStream.DecodeBool(); var id = rlpStream.DecodeString(); var initializerName = rlpStream.DecodeString(); var storeConfigInDatabase = rlpStream.DecodeBool(); var verifyP2PSignature = rlpStream.DecodeBool(); var persistence = rlpStream.DecodeString(); var faucetEnabled = rlpStream.DecodeBool(); var faucetAddress = rlpStream.DecodeString(); var faucetHost = rlpStream.DecodeString(); var faucetWeiRequestMaxValue = rlpStream.DecodeUInt256(); var faucetEthDailyRequestsTotalValue = rlpStream.DecodeUInt256(); var consumerAddress = rlpStream.DecodeString(); var contractAddress = rlpStream.DecodeString(); var providerName = rlpStream.DecodeString(); var providerAddress = rlpStream.DecodeString(); var providerColdWalletAddress = rlpStream.DecodeString(); var receiptRequestThreshold = rlpStream.DecodeUInt256(); var receiptsMergeThreshold = rlpStream.DecodeUInt256(); var paymentClaimThreshold = rlpStream.DecodeUInt256(); var blockConfirmations = rlpStream.DecodeUInt(); var filesPath = rlpStream.DecodeString(); var fileMaxSize = rlpStream.DecodeUlong(); var pluginsPath = rlpStream.DecodeString(); var databasePath = rlpStream.DecodeString(); var proxyEnabled = rlpStream.DecodeBool(); var jsonRpcUrlProxies = rlpStream.DecodeArray(c => c.DecodeString()); var gasPriceType = rlpStream.DecodeString(); var gasPrice = rlpStream.DecodeUInt256(); var cancelTransactionGasPricePercentageMultiplier = rlpStream.DecodeUInt(); var jsonRpcDataChannelEnabled = rlpStream.DecodeBool(); return(new NdmConfig { Enabled = enabled, Id = id, InitializerName = initializerName, StoreConfigInDatabase = storeConfigInDatabase, VerifyP2PSignature = verifyP2PSignature, Persistence = persistence, FaucetEnabled = faucetEnabled, FaucetAddress = faucetAddress, FaucetHost = faucetHost, FaucetWeiRequestMaxValue = faucetWeiRequestMaxValue, FaucetEthDailyRequestsTotalValue = faucetEthDailyRequestsTotalValue, ConsumerAddress = consumerAddress, ContractAddress = contractAddress, ProviderName = providerName, ProviderAddress = providerAddress, ProviderColdWalletAddress = providerColdWalletAddress, ReceiptRequestThreshold = receiptRequestThreshold, ReceiptsMergeThreshold = receiptsMergeThreshold, PaymentClaimThreshold = paymentClaimThreshold, BlockConfirmations = blockConfirmations, FilesPath = filesPath, FileMaxSize = fileMaxSize, PluginsPath = pluginsPath, DatabasePath = databasePath, ProxyEnabled = proxyEnabled, JsonRpcUrlProxies = jsonRpcUrlProxies, GasPriceType = gasPriceType, GasPrice = gasPrice, CancelTransactionGasPricePercentageMultiplier = cancelTransactionGasPricePercentageMultiplier, JsonRpcDataChannelEnabled = jsonRpcDataChannelEnabled }); }