This repository has been archived by the owner on Jan 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
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
Showing
5 changed files
with
123 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// Copyright 2022-2023 Protocol Labs | ||
// SPDX-License-Identifier: MIT | ||
//! Subnet bootstrap-related commands | ||
use async_trait::async_trait; | ||
use clap::Args; | ||
use ipc_sdk::subnet_id::SubnetID; | ||
use std::{fmt::Debug, str::FromStr}; | ||
|
||
use crate::{get_ipc_provider, require_fil_addr_from_str, CommandLineHandler, GlobalArguments}; | ||
|
||
/// The command to add a bootstrap subnet | ||
pub struct AddBootstrap; | ||
|
||
#[async_trait] | ||
impl CommandLineHandler for AddBootstrap { | ||
type Arguments = AddBootstrapArgs; | ||
|
||
async fn handle(global: &GlobalArguments, arguments: &Self::Arguments) -> anyhow::Result<()> { | ||
log::debug!("add subnet bootstrap with args: {:?}", arguments); | ||
|
||
let mut provider = get_ipc_provider(global)?; | ||
let subnet = SubnetID::from_str(&arguments.subnet)?; | ||
let from = match &arguments.from { | ||
Some(address) => Some(require_fil_addr_from_str(address)?), | ||
None => None, | ||
}; | ||
|
||
provider | ||
.add_bootstrap(&subnet, from, arguments.endpoint.clone()) | ||
.await | ||
} | ||
} | ||
|
||
#[derive(Debug, Args)] | ||
#[command(name = "add-bootstrap", about = "Advertise bootstrap in the subnet")] | ||
pub struct AddBootstrapArgs { | ||
#[arg( | ||
long, | ||
short, | ||
help = "The address of the validator adding the bootstrap" | ||
)] | ||
pub from: Option<String>, | ||
#[arg(long, short, help = "The subnet to add the bootstrap to")] | ||
pub subnet: String, | ||
#[arg(long, short, help = "The bootstrap node's network endpoint")] | ||
pub endpoint: String, | ||
} |
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