Skip to content

Commit 75cc08f

Browse files
committed
primitives - sentry - rename ChannelAllResponse to ChannelListResponse and use it in the response
1 parent 7f0fcd8 commit 75cc08f

File tree

3 files changed

+9
-17
lines changed

3 files changed

+9
-17
lines changed

primitives/src/sentry.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,9 @@ pub struct AggregateEvents {
7575
pub event_payouts: HashMap<String, BigNum>,
7676
}
7777

78-
#[derive(Deserialize, Debug)]
78+
#[derive(Debug, Serialize, Deserialize)]
7979
#[serde(rename_all = "camelCase")]
80-
pub struct ChannelAllResponse {
80+
pub struct ChannelListResponse {
8181
pub channels: Vec<Channel>,
8282
pub total_pages: u64,
8383
}

sentry/src/routes/channel.rs

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use self::channel_list::ChannelListQuery;
22
use crate::db::{get_channel_by_id, insert_channel, list_channels};
3-
use crate::routes::channel::channel_list::ChannelListResponse;
43
use crate::success_response;
54
use crate::Application;
65
use crate::ResponseError;
@@ -9,7 +8,7 @@ use futures::TryStreamExt;
98
use hex::FromHex;
109
use hyper::{Body, Request, Response};
1110
use primitives::adapter::Adapter;
12-
use primitives::sentry::SuccessResponse;
11+
use primitives::sentry::{ChannelListResponse, SuccessResponse};
1312
use primitives::{Channel, ChannelId};
1413
use slog::error;
1514

@@ -119,15 +118,8 @@ pub async fn last_approved<A: Adapter>(
119118
mod channel_list {
120119
use chrono::serde::ts_seconds::deserialize as ts_seconds;
121120
use chrono::{DateTime, Utc};
122-
use primitives::{Channel, ValidatorId};
123-
use serde::{Deserialize, Serialize};
124-
125-
#[derive(Debug, Serialize)]
126-
#[serde(rename_all = "camelCase")]
127-
pub(super) struct ChannelListResponse {
128-
pub channels: Vec<Channel>,
129-
pub total_pages: u64,
130-
}
121+
use primitives::ValidatorId;
122+
use serde::Deserialize;
131123

132124
#[derive(Debug, Deserialize)]
133125
pub(super) struct ChannelListQuery {

validator_worker/src/sentry_interface.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use futures_legacy::Future as LegacyFuture;
66
use primitives::adapter::Adapter;
77
use primitives::channel::SpecValidator;
88
use primitives::sentry::{
9-
ChannelAllResponse, EventAggregateResponse, LastApprovedResponse, SuccessResponse,
9+
ChannelListResponse, EventAggregateResponse, LastApprovedResponse, SuccessResponse,
1010
ValidatorMessageResponse,
1111
};
1212
use primitives::validator::MessageTypes;
@@ -230,7 +230,7 @@ pub async fn all_channels(
230230
if first_page.total_pages < 2 {
231231
Ok(first_page.channels)
232232
} else {
233-
let mut all: Vec<ChannelAllResponse> = try_join_all(
233+
let mut all: Vec<ChannelListResponse> = try_join_all(
234234
(1..first_page.total_pages).map(|i| fetch_page(url.clone(), i, whoami.clone())),
235235
)
236236
.await?;
@@ -248,7 +248,7 @@ async fn fetch_page(
248248
sentry_url: String,
249249
page: u64,
250250
validator: String,
251-
) -> Result<ChannelAllResponse, reqwest::Error> {
251+
) -> Result<ChannelListResponse, reqwest::Error> {
252252
let client = Client::new();
253253

254254
let mut query = vec![format!("page={}", page)];
@@ -257,7 +257,7 @@ async fn fetch_page(
257257
let future = client
258258
.get(format!("{}/channel/list?{}", sentry_url, query.join("&")).as_str())
259259
.send()
260-
.and_then(|mut res: Response| res.json::<ChannelAllResponse>());
260+
.and_then(|mut res: Response| res.json::<ChannelListResponse>());
261261

262262
future.compat().await
263263
}

0 commit comments

Comments
 (0)