Skip to content

Commit

Permalink
Fix rustfmt and clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
pietrodimarco-dfinity committed Jan 30, 2025
1 parent 611f1c5 commit 63d64b4
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 31 deletions.
29 changes: 28 additions & 1 deletion rs/pocket_ic_server/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@ pub mod pocket_ic;
pub mod state_api;

use crate::state_api::state::OpOut;
use ::pocket_ic::common::rest::{BinaryBlob, BlobId};
use ::pocket_ic::common::rest::{BinaryBlob, BlobId, RawSubnetBlockmakerMetrics};
use axum::async_trait;
use candid::Principal;
use ic_types::{NodeId, PrincipalId, SubnetId};
use pocket_ic::PocketIc;
use serde::Deserialize;

Expand Down Expand Up @@ -91,3 +93,28 @@ pub fn copy_dir(
}
Ok(())
}

#[derive(Clone, Debug)]
pub struct SubnetBlockmakerMetrics {
pub subnet: SubnetId,
pub blockmaker: NodeId,
pub failed_blockmakers: Vec<NodeId>,
}

impl From<RawSubnetBlockmakerMetrics> for SubnetBlockmakerMetrics {
fn from(raw: RawSubnetBlockmakerMetrics) -> Self {
let subnet = SubnetId::from(PrincipalId::from(Principal::from(raw.subnet)));
let blockmaker = NodeId::from(PrincipalId::from(Principal::from(raw.blockmaker)));
let failed_blockmakers: Vec<NodeId> = raw
.failed_blockmakers
.into_iter()
.map(|node_id| NodeId::from(PrincipalId::from(Principal::from(node_id))))
.collect();

SubnetBlockmakerMetrics {
subnet,
blockmaker,
failed_blockmakers,
}
}
}
33 changes: 3 additions & 30 deletions rs/pocket_ic_server/src/pocket_ic.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::state_api::state::{HasStateLabel, OpOut, PocketIcError, StateLabel};
use crate::{async_trait, copy_dir, BlobStore, OpId, Operation};
use crate::{async_trait, copy_dir, BlobStore, OpId, Operation, SubnetBlockmakerMetrics};
use askama::Template;
use axum::{
extract::State,
Expand Down Expand Up @@ -78,8 +78,7 @@ use pocket_ic::common::rest::{
self, BinaryBlob, BlobCompression, CanisterHttpHeader, CanisterHttpMethod, CanisterHttpRequest,
CanisterHttpResponse, ExtendedSubnetConfigSet, MockCanisterHttpResponse, RawAddCycles,
RawCanisterCall, RawCanisterId, RawEffectivePrincipal, RawMessageId, RawSetStableMemory,
RawSubnetBlockmakerMetrics, SubnetInstructionConfig, SubnetKind, SubnetSpec, TickConfigs,
Topology,
SubnetInstructionConfig, SubnetKind, SubnetSpec, TickConfigs, Topology,
};
use pocket_ic::{ErrorCode, RejectCode, RejectResponse};
use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -1632,8 +1631,7 @@ impl Operation for Tick {
}
}

let subnets = pic.subnets.subnets.read().unwrap();
for (_, subnet) in subnets.iter() {
for subnet in pic.subnets.get_all() {
subnet.state_machine.execute_round();
}
OpOut::NoOutput
Expand All @@ -1644,31 +1642,6 @@ impl Operation for Tick {
}
}

#[derive(Clone, Debug)]
pub struct SubnetBlockmakerMetrics {
pub subnet: SubnetId,
pub blockmaker: NodeId,
pub failed_blockmakers: Vec<NodeId>,
}

impl From<RawSubnetBlockmakerMetrics> for SubnetBlockmakerMetrics {
fn from(raw: RawSubnetBlockmakerMetrics) -> Self {
let subnet = SubnetId::from(PrincipalId::from(Principal::from(raw.subnet)));
let blockmaker = NodeId::from(PrincipalId::from(Principal::from(raw.blockmaker)));
let failed_blockmakers: Vec<NodeId> = raw
.failed_blockmakers
.into_iter()
.map(|node_id| NodeId::from(PrincipalId::from(Principal::from(node_id))))
.collect();

SubnetBlockmakerMetrics {
subnet,
blockmaker,
failed_blockmakers,
}
}
}

#[derive(Copy, Clone, Debug)]
pub struct AdvanceTimeAndTick(pub Duration);

Expand Down

0 comments on commit 63d64b4

Please sign in to comment.