This repository has been archived by the owner on May 18, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ce4c242
commit 85e6ad0
Showing
2 changed files
with
29 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,35 @@ | ||
use actix_web::HttpResponse; | ||
use actix_web::{ | ||
web::Data, | ||
HttpResponse, | ||
}; | ||
use serde::Serialize; | ||
|
||
use crate::{server::error::ValidatorServerError, key_manager}; | ||
use crate::server::routes::sign::Config; | ||
|
||
#[derive(Serialize)] | ||
struct IndexBody { | ||
struct IndexBody<'a> { | ||
version: &'static str, | ||
address: &'a str, | ||
bundler_address: &'a str, | ||
block_height: u128, | ||
epoch: u128, | ||
} | ||
|
||
pub async fn index() -> actix_web::Result<HttpResponse> { | ||
pub async fn index<Context, KeyManager>( | ||
ctx: Data<Context>, | ||
) -> actix_web::Result<HttpResponse, ValidatorServerError> | ||
where | ||
Context: self::Config<KeyManager>, | ||
KeyManager: key_manager::KeyManager, | ||
{ | ||
let body = IndexBody { | ||
version: env!("CARGO_PKG_VERSION"), | ||
address: &ctx.validator_address(), | ||
bundler_address: ctx.bundler_address(), | ||
block_height: ctx.current_block(), | ||
epoch: ctx.current_epoch(), | ||
}; | ||
|
||
Ok(HttpResponse::Ok().json(body)) | ||
} |