コード例 #1
0
        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));
        }
コード例 #2
0
        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));
        }
コード例 #3
0
        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
            });
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        public TransactionInfo Decode(RlpStream rlpStream, RlpBehaviors rlpBehaviors = RlpBehaviors.None)
        {
            var sequenceLength = rlpStream.ReadSequenceLength();

            if (sequenceLength == 0)
            {
                return(null);
            }

            var hash      = rlpStream.DecodeKeccak();
            var value     = rlpStream.DecodeUInt256();
            var gasPrice  = rlpStream.DecodeUInt256();
            var gasLimit  = rlpStream.DecodeUlong();
            var timestamp = rlpStream.DecodeUlong();
            var state     = (TransactionState)rlpStream.DecodeInt();

            return(new TransactionInfo(hash, value, gasPrice, gasLimit, timestamp, state));
        }
コード例 #6
0
        public TransactionInfo Decode(RlpStream rlpStream, RlpBehaviors rlpBehaviors = RlpBehaviors.None)
        {
            rlpStream.ReadSequenceLength();
            try
            {
                Keccak           hash      = rlpStream.DecodeKeccak();
                UInt256          value     = rlpStream.DecodeUInt256();
                UInt256          gasPrice  = rlpStream.DecodeUInt256();
                ulong            gasLimit  = rlpStream.DecodeUlong();
                ulong            timestamp = rlpStream.DecodeUlong();
                TransactionType  type      = (TransactionType)rlpStream.DecodeInt();
                TransactionState state     = (TransactionState)rlpStream.DecodeInt();

                return(new TransactionInfo(hash, value, gasPrice, gasLimit, timestamp, type, state));
            }
            catch (Exception e)
            {
                throw new RlpException($"{nameof(TransactionInfo)} could not be decoded", e);
            }
        }
コード例 #7
0
        public DepositApproval Decode(RlpStream rlpStream,
                                      RlpBehaviors rlpBehaviors = RlpBehaviors.None)
        {
            rlpStream.ReadSequenceLength();
            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(assetId, assetName, kyc, consumer, provider, timestamp, state));
        }
コード例 #8
0
        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));
        }
コード例 #9
0
        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);
        }
コード例 #10
0
        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));
        }
コード例 #11
0
        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));
        }
コード例 #12
0
        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
                });
            }
コード例 #13
0
        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
            });
        }