Esempio n. 1
0
        public void ChangeState(DataHeaderState state)
        {
            if (State == state || State == DataHeaderState.Archived)
            {
                return;
            }

            State = state;
        }
 public DataHeaderStateChangedMessage(Keccak dataHeaderId, DataHeaderState state)
 {
     DataHeaderId = dataHeaderId;
     State        = state;
 }
Esempio n. 3
0
        public DataHeader(Keccak id, string name, string description, UInt256 unitPrice,
                          DataHeaderUnitType unitType, uint minUnits, uint maxUnits, DataHeaderRules rules,
                          DataHeaderProvider provider, string file = null, QueryType queryType           = QueryType.Stream,
                          DataHeaderState state = DataHeaderState.Unpublished, string termsAndConditions = null,
                          bool kycRequired      = false)
        {
            if (provider == null || string.IsNullOrWhiteSpace(provider.Name) || provider.Address == null)
            {
                throw new ArgumentException("Invalid data header provider.", nameof(provider));
            }

            if (id == Keccak.Zero)
            {
                throw new ArgumentException("Invalid data header id.", nameof(id));
            }

            if (string.IsNullOrWhiteSpace(name) || name.Length > 100)
            {
                throw new ArgumentException("Invalid data header name.", nameof(name));
            }

            if (string.IsNullOrWhiteSpace(description) || description.Length > 256)
            {
                throw new ArgumentException("Invalid data header description.", nameof(description));
            }

            if (termsAndConditions?.Length > 10000)
            {
                throw new ArgumentException("Invalid terms and conditions (over 10000 chars).", nameof(description));
            }

            if (rules is null)
            {
                throw new ArgumentException($"Missing rules.", nameof(rules));
            }

            if (rules.Expiry is null && rules.Expiry.Value <= 0)
            {
                throw new ArgumentException($"Invalid expiry rule value: {rules.Expiry}.", nameof(rules.Expiry));
            }

            if (!(rules.UpfrontPayment is null) && rules.UpfrontPayment.Value > minUnits)
            {
                throw new ArgumentException($"Min units ({minUnits}) cannot be lower than upfront payment value" +
                                            $" ({rules.UpfrontPayment.Value}).", nameof(minUnits));
            }

            Provider           = provider;
            State              = state;
            Id                 = id;
            Name               = name;
            Description        = description;
            UnitPrice          = unitPrice;
            UnitType           = unitType;
            QueryType          = queryType;
            MinUnits           = minUnits;
            MaxUnits           = maxUnits;
            Rules              = rules;
            Provider           = provider;
            File               = file;
            State              = state;
            TermsAndConditions = termsAndConditions;
            KycRequired        = kycRequired;
        }