-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into weighted_validators
- Loading branch information
Showing
12 changed files
with
266 additions
and
293 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
This file was deleted.
Oops, something went wrong.
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,23 +1,16 @@ | ||
//! Health check method for RPC server. | ||
use super::RPCMethod; | ||
use jsonrpsee::types::{error::ErrorCode, Params}; | ||
use jsonrpsee::core::RpcResult; | ||
|
||
/// Health check method for RPC server. | ||
pub struct HealthCheck; | ||
|
||
impl RPCMethod for HealthCheck { | ||
/// Health check response for /health endpoint. | ||
fn callback(_params: Params) -> Result<serde_json::Value, ErrorCode> { | ||
Ok(serde_json::json!({"health": true})) | ||
} | ||
/// Health check response for /health endpoint. | ||
pub fn callback() -> RpcResult<serde_json::Value> { | ||
Ok(serde_json::json!({"health": true})) | ||
} | ||
|
||
/// Health check method name. | ||
fn method() -> &'static str { | ||
"health_check" | ||
} | ||
/// Health check method name. | ||
pub fn method() -> &'static str { | ||
"health_check" | ||
} | ||
|
||
/// Method path for GET requests. | ||
fn path() -> &'static str { | ||
"/health" | ||
} | ||
/// Method path for GET requests. | ||
pub fn path() -> &'static str { | ||
"/health" | ||
} |
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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
//! Peers method for RPC server. | ||
use anyhow::Context; | ||
use jsonrpsee::{ | ||
core::RpcResult, | ||
types::{error::ErrorCode, ErrorObjectOwned}, | ||
}; | ||
use std::sync::Arc; | ||
use zksync_consensus_storage::BlockStore; | ||
|
||
/// Last view response for /last_view endpoint. | ||
pub fn callback(node_storage: Arc<BlockStore>) -> RpcResult<serde_json::Value> { | ||
let sub = &mut node_storage.subscribe(); | ||
let state = sub.borrow().clone(); | ||
let last_commited_block_header = state | ||
.last | ||
.context("Failed to get last state") | ||
.map_err(|_| ErrorObjectOwned::from(ErrorCode::InternalError))? | ||
.header() | ||
.number | ||
.0; | ||
Ok(serde_json::json!({ | ||
"last_commited_block": last_commited_block_header | ||
})) | ||
} | ||
|
||
/// Last view method name. | ||
pub fn method() -> &'static str { | ||
"last_commited_block" | ||
} | ||
|
||
/// Method path for GET requests. | ||
pub fn path() -> &'static str { | ||
"/last_commited_block" | ||
} |
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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
//! Peers method for RPC server. | ||
use anyhow::Context; | ||
use jsonrpsee::{ | ||
core::RpcResult, | ||
types::{error::ErrorCode, ErrorObjectOwned}, | ||
}; | ||
use std::sync::Arc; | ||
use zksync_consensus_storage::BlockStore; | ||
|
||
/// Last view response for /last_view endpoint. | ||
pub fn callback(node_storage: Arc<BlockStore>) -> RpcResult<serde_json::Value> { | ||
let sub = &mut node_storage.subscribe(); | ||
let state = sub.borrow().clone(); | ||
let last_view = state | ||
.last | ||
.context("Failed to get last state") | ||
.map_err(|_| ErrorObjectOwned::from(ErrorCode::InternalError))? | ||
.view() | ||
.number | ||
.0; | ||
Ok(serde_json::json!({ | ||
"last_view": last_view | ||
})) | ||
} | ||
|
||
/// Last view method name. | ||
pub fn method() -> &'static str { | ||
"last_view" | ||
} | ||
|
||
/// Method path for GET requests. | ||
pub fn path() -> &'static str { | ||
"/last_view" | ||
} |
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,3 @@ | ||
use jsonrpsee::types::{error::ErrorCode, Params}; | ||
|
||
/// Trait to implement for new RPC methods. | ||
pub trait RPCMethod { | ||
/// Method response logic when called. | ||
fn callback(params: Params) -> Result<serde_json::Value, ErrorCode>; | ||
/// Method name. | ||
fn method() -> &'static str; | ||
/// Method path for GET requests. | ||
fn path() -> &'static str; | ||
} | ||
|
||
pub(crate) mod config; | ||
pub mod health_check; | ||
pub(crate) mod peers; | ||
pub mod last_commited_block; | ||
pub mod last_view; |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.