Skip to content

Commit

Permalink
feat: add is first startup init mode request
Browse files Browse the repository at this point in the history
  • Loading branch information
raindust committed Feb 8, 2024
1 parent 63c6660 commit 577b304
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 2 deletions.
1 change: 1 addition & 0 deletions codecs/runtime-codec/src/vmh/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ pub struct EnvSettings {
pub replica_test_mode: bool,
pub apply_validator: bool,
pub test_mode: bool,
pub first_startup_init_mode: bool,
pub lastest_topup_height: u64,
pub startup_proof: Option<String>,
pub settings: HashMap<String, String>,
Expand Down
9 changes: 9 additions & 0 deletions system-actors/src/env/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,15 @@ pub struct IsMainNetRequest;
#[derive(Debug, Clone, Serialize, Deserialize, TypeId)]
pub struct IsMainNetResponse(pub bool);

#[doc(hidden)]
#[derive(Debug, Clone, Serialize, Deserialize, TypeId, Priced)]
#[price(10000)]
pub struct IsFirstStartupInitModeRequest;

#[doc(hidden)]
#[derive(Debug, Clone, Serialize, Deserialize, TypeId)]
pub struct IsFirstStartupInitModeResponse(pub bool);

#[doc(hidden)]
#[derive(Debug, Clone, Serialize, Deserialize, TypeId, Priced)]
#[price(10000)]
Expand Down
8 changes: 8 additions & 0 deletions system-actors/src/tokenstate_service/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ pub struct IsOutdatedRequest(pub ActorId);
#[derive(Debug, Clone, Serialize, Deserialize, TypeId)]
pub struct IsOutdatedResponse(pub bool);

#[doc(hidden)]
#[derive(Debug, Clone, Serialize, Deserialize, TypeId)]
pub struct HasStateInitRequest;

#[doc(hidden)]
#[derive(Debug, Clone, Serialize, Deserialize, TypeId)]
pub struct HasStateInitResponse(pub bool);

#[doc(hidden)]
#[derive(Debug, Clone, Serialize, Deserialize, TypeId)]
#[response(Vec<u8>)]
Expand Down
10 changes: 8 additions & 2 deletions utils/wasm-actor-utils/src/enclave/actors/libp2p.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,17 @@ pub async fn my_conn_id() -> Result<String> {
}

#[doc(hidden)]
pub async fn is_connection_healthy() -> Result<bool> {
pub async fn has_libp2p_cooldown() -> Result<bool> {
let cooldown = ActorId::Static(tea_system_actors::libp2p::NAME)
.call(HasCooldownRequest)
.await?;
if !cooldown.0 {
Ok(cooldown.0)
}

#[doc(hidden)]
pub async fn is_connection_healthy() -> Result<bool> {
let cooldown = has_libp2p_cooldown().await?;
if !cooldown {
return Ok(false);
}
match connected_peers().await {
Expand Down

0 comments on commit 577b304

Please sign in to comment.