Struct primitives::config::Config

source ·
pub struct Config {
    pub worker: ValidatorWorkerConfig,
    pub sentry: SentryConfig,
    pub creators_whitelist: Vec<Address>,
    pub validators_whitelist: Vec<ValidatorId>,
    pub chains: HashMap<String, ChainInfo>,
    pub limits: Limits,
}
Expand description

Examples:

use primitives::{config::GANACHE_CONFIG, Config};
use serde_json::{from_value, json};

fn main() {
    let json = json!({
      "creators_whitelist": [
        "0xaCBaDA2d5830d1875ae3D2de207A1363B316Df2F",
        "0xDd589B43793934EF6Ad266067A0d1D4896b0dff0",
        "0xE882ebF439207a70dDcCb39E13CA8506c9F45fD9",
        "0x541b401362Ea1D489D322579552B099e801F3632"
      ],
      "validators_whitelist": [
        "0x80690751969B234697e9059e04ed72195c3507fa",
        "0xf3f583AEC5f7C030722Fe992A5688557e1B86ef7",
        "0x6B83e7D6B72c098d48968441e0d05658dc17Adb9"
      ],
      "chain": {
        "Ganache #1337": {
          "chain_id": 1337,
          "rpc": "http://localhost:1337/",
          "outpace": "0xAbc27d46a458E2e49DaBfEf45ca74dEDBAc3DD06",
          "token": {
            "Mocked TOKEN 1337": {
              "min_campaign_budget": "1000000000000000000",
              "min_validator_fee": "1000000000000",
              "precision": 18,
              "address": "0x2BCaf6968aEC8A3b5126FBfAb5Fd419da6E8AD8E"
            }
          }
        },
        "Ganache #1": {
          "chain_id": 1,
          "rpc": "http://localhost:8545/",
          "outpace": "0x26CBc2eAAe377f6Ac4b73a982CD1125eF4CEC96f",
          "token": {
            "Mocked TOKEN 1": {
              "min_campaign_budget": "1000000000000000000",
              "min_validator_fee": "1000000000000",
              "precision": 18,
              "address": "0x12a28f2bfBFfDf5842657235cC058242f40fDEa6"
            }
          }
        }
      },
      "limits": {
        "units_for_slot": {
          "max_campaigns_earning_from": 25,
          "global_min_impression_price": "10"
        },
        "channels_find": 200,
        "campaigns_find": 200,
        "spendable_find": 200,
        "msgs_find": 10,
        "analytics_find": 5000,
        "ip_rate_limit": {
          "type": "ip",
          "timeframe": 1200000
        }
      },
      "sentry": {
        "analytics_maxtime": 20000,
        "admins": [
          "0x80690751969B234697e9059e04ed72195c3507fa"
        ],
        "platform": {
          "url": "https://platform.adex.network/",
          "keep_alive_interval": 1200000
        },
      },
      "worker": {
        "max_channels": 512,
        "wait_time": 500,
        "heartbeat_time": 30000,
        "health_threshold_promilles": 950,
        "health_unsignable_promilles": 750,
        "timeouts": {
          "propagation": 2000,
          "fetch": 5000,
          "all_campaigns": 5000,
          "channel_tick": 8000,
        }
      }
    });
    assert_eq!(
        from_value::<Config>(json).expect("Should deserialize"),
        GANACHE_CONFIG.clone()
    );
}

Fields

worker: ValidatorWorkerConfig

Values used for the validator worker

sentry: SentryConfig

Values used for the sentry

creators_whitelist: Vec<Address>

An optional whitelisted addresses for Campaign.creators.

If empty, any address will be allowed to create a Campaign.

validators_whitelist: Vec<ValidatorId>

An optional whitelisted Validator addresses for Campaign.validators.

If empty, any address will be allowed to be a validator in a Campaign.

chains: HashMap<String, ChainInfo>

The key of this map is a human-readable text of the Chain name for readability in the configuration file.

NOTE: Make sure that a Token Address is unique across all Chains, otherwise Config::find_chain_of() will fetch only one of them and cause unexpected problems.

limits: Limits

Any limits applied to Sentry or Validator.

Implementations

Utility method that will deserialize a Toml file content into a Config.

Rather than relying on the toml crate directly, use this method instead.

Finds a Chain based on the ChainId.

Finds the pair of Chain & Token, given only a token Address.

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Deserialize this value from the given Serde deserializer. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more
Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The alignment of pointer.
The type for initializers.
Initializes a with the given initializer. Read more
Dereferences the given pointer. Read more
Mutably dereferences the given pointer. Read more
Drops the object pointed to by the given pointer. Read more
Should always be Self
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more