Skip to content

Commit 3ff99e9

Browse files
author
Ivo Georgiev
authored
Merge pull request #264 from AdExNetwork/dev
fast-forward master to dev
2 parents 3b9fe57 + fb0ec9b commit 3ff99e9

File tree

26 files changed

+831
-129
lines changed

26 files changed

+831
-129
lines changed

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ RUN apt update && apt-get install -y libssl-dev
3838

3939
COPY --from=builder /usr/local/bin/validator_worker .
4040

41-
ENTRYPOINT validator_worker -a ${ADAPTER:-ethereum} \
41+
CMD validator_worker -a ${ADAPTER:-ethereum} \
4242
${KEYSTORE_FILE:+-k $KEYSTORE_FILE} \
4343
${DUMMY_IDENTITY:+-i $DUMMY_IDENTITY} \
4444
${SINGLE_TICK:+-t} \
45-
${SENTRY_URL:+-u $SENTRY_URL} ${CONFIG}
45+
${SENTRY_URL:+-u $SENTRY_URL} ${CONFIG}

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ you need to be running those in order to run the automated tests:
4545

4646
TODO
4747

48+
### Bug
49+
50+
51+
52+
4853
### Run Validator Worker
4954

5055
TODO

adapter/src/ethereum.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,10 @@ mod test {
594594
token_contract
595595
.call(
596596
"setBalanceTo",
597-
(Token::Address(leader_account), Token::Uint(2000.into())),
597+
(
598+
Token::Address(leader_account),
599+
Token::Uint(U256::from(2000 as u64)),
600+
),
598601
leader_account,
599602
Options::default(),
600603
)
@@ -645,6 +648,7 @@ mod test {
645648
nonce: None,
646649
withdraw_period_start: Utc::now() + Duration::days(1),
647650
ad_units: vec![],
651+
pricing_bounds: None,
648652
},
649653
};
650654

docs/config/prod.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
max_channels = 512
33

44
channels_find_limit = 512
5-
wait_time = 500
5+
wait_time = 40000
66

7-
aggr_throttle = 5000
7+
aggr_throttle = 40000
88
events_find_limit = 100
99
msgs_find_limit = 10
1010

@@ -17,7 +17,7 @@ list_timeout = 10000
1717
fetch_timeout = 10000
1818
validator_tick_timeout = 10000
1919

20-
ip_rate_limit = { type = 'ip', timeframe = 20000 }
20+
ip_rate_limit = { type = 'ip', timeframe = 1200000 }
2121
sid_rate_limit = { type = 'sid', timeframe = 0 }
2222
ethereum_core_address = '0x333420fc6a897356e69b62417cd17ff012177d2b'
2323
ethereum_network = 'http://localhost:8545'
@@ -26,5 +26,5 @@ ethereum_adapter_relayer = 'https://relayer.adex.network'
2626
creators_whitelist = []
2727
minimal_deposit = "0"
2828
minimal_fee = "0"
29-
token_address_whitelist = ['0x89d24A6b4CcB1B6fAA2625fE562bDD9a23260359']
29+
token_address_whitelist = ['0x89d24A6b4CcB1B6fAA2625fE562bDD9a23260359', '0x6B175474E89094C44Da98b954EedeAC495271d0F']
3030
validators_whitelist = []

primitives/src/analytics.rs

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,42 @@
1+
use crate::ChannelId;
12
use crate::DomainError;
23
use serde::{Deserialize, Serialize};
34

45
pub const ANALYTICS_QUERY_LIMIT: u32 = 200;
56

7+
#[derive(Debug, Serialize, Deserialize)]
8+
#[serde(rename_all = "camelCase")]
9+
pub struct AnalyticsData {
10+
pub time: f64,
11+
pub value: String,
12+
#[serde(default, skip_serializing_if = "Option::is_none")]
13+
pub channel_id: Option<ChannelId>,
14+
}
15+
616
#[derive(Debug, Serialize, Deserialize)]
717
pub struct AnalyticsResponse {
8-
time: u32,
9-
value: String,
18+
pub aggr: Vec<AnalyticsData>,
19+
pub limit: u32,
1020
}
1121

1222
#[cfg(feature = "postgres")]
1323
pub mod postgres {
14-
use super::AnalyticsResponse;
24+
use super::AnalyticsData;
1525
use tokio_postgres::Row;
1626

17-
impl From<&Row> for AnalyticsResponse {
27+
impl From<&Row> for AnalyticsData {
1828
fn from(row: &Row) -> Self {
1929
Self {
2030
time: row.get("time"),
2131
value: row.get("value"),
32+
channel_id: row.try_get("channel_id").ok(),
2233
}
2334
}
2435
}
2536
}
2637

2738
#[derive(Debug, Deserialize)]
39+
#[serde(rename_all = "camelCase")]
2840
pub struct AnalyticsQuery {
2941
#[serde(default = "default_limit")]
3042
pub limit: u32,
@@ -34,6 +46,7 @@ pub struct AnalyticsQuery {
3446
pub metric: String,
3547
#[serde(default = "default_timeframe")]
3648
pub timeframe: String,
49+
pub segment_by_channel: Option<String>,
3750
}
3851

3952
impl AnalyticsQuery {

primitives/src/big_num.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,19 @@ use num_derive::{Num, NumOps, One, Zero};
1010
use serde::{Deserialize, Deserializer, Serialize, Serializer};
1111

1212
#[derive(
13-
Serialize, Deserialize, Debug, Clone, PartialEq, Eq, PartialOrd, Ord, NumOps, One, Zero, Num,
13+
Serialize,
14+
Deserialize,
15+
Debug,
16+
Clone,
17+
PartialEq,
18+
Eq,
19+
PartialOrd,
20+
Ord,
21+
NumOps,
22+
One,
23+
Zero,
24+
Num,
25+
Default,
1426
)]
1527
pub struct BigNum(
1628
#[serde(

primitives/src/channel.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,19 @@ pub struct Channel {
6363
pub spec: ChannelSpec,
6464
}
6565

66+
#[derive(Serialize, Deserialize, Debug, Clone)]
67+
pub struct Pricing {
68+
pub max: BigNum,
69+
pub min: BigNum,
70+
}
71+
72+
#[derive(Serialize, Deserialize, Debug, Clone)]
73+
#[serde(rename_all = "UPPERCASE")]
74+
pub struct PricingBounds {
75+
pub impression: Option<Pricing>,
76+
pub click: Option<Pricing>,
77+
}
78+
6679
#[derive(Serialize, Deserialize, Debug, Clone)]
6780
#[serde(rename_all = "camelCase")]
6881
pub struct ChannelSpec {
@@ -73,6 +86,8 @@ pub struct ChannelSpec {
7386
pub max_per_impression: BigNum,
7487
/// Minimum payment offered per impression
7588
pub min_per_impression: BigNum,
89+
// Event pricing bounds
90+
pub pricing_bounds: Option<PricingBounds>,
7691
/// An array of TargetingTag (optional)
7792
#[serde(default, skip_serializing_if = "Vec::is_empty")]
7893
pub targeting: Vec<TargetingTag>,
@@ -270,6 +285,12 @@ pub mod postgres {
270285
accepts!(TEXT, VARCHAR);
271286
}
272287

288+
impl From<&Row> for ChannelId {
289+
fn from(row: &Row) -> Self {
290+
row.get("id")
291+
}
292+
}
293+
273294
impl ToSql for ChannelId {
274295
fn to_sql(
275296
&self,

0 commit comments

Comments
 (0)