Skip to content

Commit daa113d

Browse files
committed
refactor(aggregator): switch epoch type from String to u64 for protocol-configuration route
1 parent 1d50739 commit daa113d

File tree

1 file changed

+3
-12
lines changed

1 file changed

+3
-12
lines changed

mithril-aggregator/src/http_server/routes/protocol_configuration_routes.rs

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ pub fn routes(
1313
fn protocol_configuration(
1414
router_state: &RouterState,
1515
) -> impl Filter<Extract = (impl warp::Reply + use<>,), Error = warp::Rejection> + Clone + use<> {
16-
warp::path!("protocol-configuration" / String)
16+
warp::path!("protocol-configuration" / u64)
1717
.and(warp::get())
1818
.and(middlewares::with_logger(router_state))
1919
.and(middlewares::with_http_message_service(router_state))
@@ -34,21 +34,12 @@ mod handlers {
3434

3535
/// Protocol Configuration
3636
pub async fn protocol_configuration(
37-
epoch: String,
37+
epoch: u64,
3838
logger: Logger,
3939
http_message_service: Arc<dyn MessageService>,
4040
allowed_discriminants: BTreeSet<SignedEntityTypeDiscriminants>,
4141
) -> Result<impl warp::Reply, Infallible> {
42-
let epoch = match epoch.parse::<u64>() {
43-
Ok(epoch) => Epoch(epoch),
44-
Err(err) => {
45-
warn!(logger, "protocol_configuration::invalid_epoch"; "error" => ?err);
46-
return Ok(reply::bad_request(
47-
"invalid_epoch".to_string(),
48-
err.to_string(),
49-
));
50-
}
51-
};
42+
let epoch = Epoch(epoch);
5243

5344
let protocol_configuration_message = http_message_service
5445
.get_protocol_configuration_message(epoch, allowed_discriminants)

0 commit comments

Comments
 (0)