Skip to content

Commit

Permalink
Update comments and delete serialize for view number
Browse files Browse the repository at this point in the history
  • Loading branch information
IAvecilla committed Mar 7, 2024
1 parent d6b904a commit c366ecc
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
2 changes: 1 addition & 1 deletion node/libs/roles/src/validator/messages/consensus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ impl std::ops::BitAnd for &Signers {
}

/// A struct that represents a view number.
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize)]
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct ViewNumber(pub u64);

impl ViewNumber {
Expand Down
20 changes: 15 additions & 5 deletions node/tools/src/rpc/methods/last_view.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,29 @@
//! Peers method for RPC server.
use jsonrpsee::core::RpcResult;
use anyhow::Context;
use jsonrpsee::{
core::RpcResult,
types::{error::ErrorCode, ErrorObjectOwned},
};
use std::sync::Arc;
use zksync_consensus_storage::BlockStore;

/// Config response for /config endpoint.
/// 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 a = state.last.unwrap().view().number;
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": a
"last_view": last_view
}))
}

/// Config method name.
/// Last view method name.
pub fn method() -> &'static str {
"last_view"
}
Expand Down

0 comments on commit c366ecc

Please sign in to comment.