Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
0
        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);
            }
        }
Ejemplo n.º 3
0
        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));
        }
Ejemplo n.º 4
0
        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));
        }
Ejemplo n.º 5
0
        public UnitsRange Decode(RlpStream rlpStream, RlpBehaviors rlpBehaviors = RlpBehaviors.None)
        {
            rlpStream.ReadSequenceLength();
            try
            {
                uint from = rlpStream.DecodeUInt();
                uint to   = rlpStream.DecodeUInt();

                return(new UnitsRange(from, to));
            }
            catch (Exception e)
            {
                throw new RlpException($"{nameof(UnitsRange)} could not be decoded", e);
            }
        }
Ejemplo n.º 6
0
        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));
        }
Ejemplo n.º 7
0
        public UnitsRange Decode(RlpStream rlpStream,
                                 RlpBehaviors rlpBehaviors = RlpBehaviors.None)
        {
            var sequenceLength = rlpStream.ReadSequenceLength();

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

            var from = rlpStream.DecodeUInt();
            var to   = rlpStream.DecodeUInt();

            return(new UnitsRange(from, to));
        }
Ejemplo n.º 8
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
            });
        }
Ejemplo n.º 9
0
        public Deposit Decode(RlpStream rlpStream,
                              RlpBehaviors rlpBehaviors = RlpBehaviors.None)
        {
            var sequenceLength = rlpStream.ReadSequenceLength();

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

            var id         = rlpStream.DecodeKeccak();
            var units      = rlpStream.DecodeUInt();
            var expiryTime = rlpStream.DecodeUInt();
            var value      = rlpStream.DecodeUInt256();

            return(new Deposit(id, units, expiryTime, value));
        }
Ejemplo n.º 10
0
        public DataDeliveryReceipt Decode(RlpStream rlpStream,
                                          RlpBehaviors rlpBehaviors = RlpBehaviors.None)
        {
            var sequenceLength = rlpStream.ReadSequenceLength();

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

            var statusCode    = (StatusCodes)rlpStream.DecodeInt();
            var consumedUnits = rlpStream.DecodeUInt();
            var unpaidUnits   = rlpStream.DecodeUInt();
            var signature     = SignatureDecoder.DecodeSignature(rlpStream);

            return(new DataDeliveryReceipt(statusCode, consumedUnits, unpaidUnits, signature));
        }
Ejemplo n.º 11
0
        public DataDeliveryReceipt Decode(RlpStream rlpStream, RlpBehaviors rlpBehaviors = RlpBehaviors.None)
        {
            try
            {
                rlpStream.ReadSequenceLength();
                StatusCodes statusCode    = (StatusCodes)rlpStream.DecodeInt();
                uint        consumedUnits = rlpStream.DecodeUInt();
                uint        unpaidUnits   = rlpStream.DecodeUInt();
                Signature   signature     = SignatureDecoder.DecodeSignature(rlpStream);

                return(new DataDeliveryReceipt(statusCode, consumedUnits, unpaidUnits, signature));
            }
            catch (Exception e)
            {
                throw new RlpException($"{nameof(DataDeliveryReceiptDecoder)} could not be decoded", e);
            }
        }
Ejemplo n.º 12
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));
        }
        public ProviderSession Decode(RlpStream rlpStream, RlpBehaviors rlpBehaviors = RlpBehaviors.None)
        {
            _ = rlpStream.ReadSequenceLength();
            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();
            var graceUnits             = rlpStream.DecodeUInt();
            var dataAvailability       = (DataAvailability)rlpStream.DecodeInt();

            return(new ProviderSession(id, depositId, dataAssetId, consumerAddress, consumerNodeId, providerAddress,
                                       providerNodeId, state, startUnitsFromProvider, startUnitsFromConsumer, startTimestamp, finishTimestamp,
                                       consumedUnits, unpaidUnits, paidUnits, settledUnits, graceUnits, dataAvailability));
        }
Ejemplo n.º 14
0
        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));
        }
Ejemplo n.º 15
0
        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));
        }
Ejemplo n.º 16
0
        public DataRequest Decode(RlpStream rlpStream,
                                  RlpBehaviors rlpBehaviors = RlpBehaviors.None)
        {
            var sequenceLength = rlpStream.ReadSequenceLength();

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

            var assetId    = rlpStream.DecodeKeccak();
            var units      = rlpStream.DecodeUInt();
            var value      = rlpStream.DecodeUInt256();
            var expiryTime = rlpStream.DecodeUInt();
            var salt       = rlpStream.DecodeByteArray();
            var provider   = rlpStream.DecodeAddress();
            var consumer   = rlpStream.DecodeAddress();
            var signature  = SignatureDecoder.DecodeSignature(rlpStream);

            return(new DataRequest(assetId, units, value, expiryTime, salt, provider, consumer, signature));
        }
Ejemplo n.º 17
0
        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));
        }
Ejemplo n.º 18
0
        public EarlyRefundTicket Decode(RlpStream rlpStream,
                                        RlpBehaviors rlpBehaviors = RlpBehaviors.None)
        {
            var sequenceLength = rlpStream.ReadSequenceLength();

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

            var depositId      = rlpStream.DecodeKeccak();
            var claimableAfter = rlpStream.DecodeUInt();
            var signature      = SignatureDecoder.DecodeSignature(rlpStream);

            return(new EarlyRefundTicket(depositId, claimableAfter, signature));
        }
Ejemplo n.º 19
0
        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));
        }
Ejemplo n.º 20
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
            });
        }
Ejemplo n.º 21
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
                });
            }
Ejemplo n.º 22
0
        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));
            }
        }