Skip to content
Snippets Groups Projects
Select Git revision
  • 94ed2f47cbaaef483fcbc16491f947c9e11b3c41
  • master default protected
  • json-output
  • nostr
  • 48-error-base-58-requirement-is-violated
  • no-rename
  • hugo/tx-comments
  • poka/dev
  • hugo/dev
  • tuxmain/mail
  • 0.4.3-RC2
  • 0.4.3-RC1
  • 0.4.2
  • 0.4.1
  • 0.4.0
  • 0.3.0
  • 0.2.17
  • 0.2.16
  • 0.2.15
  • 0.2.14
  • 0.2.13
  • 0.2.12
  • 0.2.10
  • 0.2.9
  • 0.2.8
  • 0.2.7
  • 0.2.6
  • 0.2.5
  • 0.2.4
  • 0.2.3
30 results

smith.rs

Blame
  • smith.rs 8.19 KiB
    use crate::*;
    
    use std::ops::Deref;
    
    type SessionKeys = [u8; 128];
    #[cfg(feature = "gdev")]
    type SmithMembershipMetaData =
    	runtime::runtime_types::common_runtime::entities::SmithMembershipMetaData<SessionKeys>;
    
    /// define smith subcommands
    #[derive(Clone, Default, Debug, clap::Parser)]
    pub enum Subcommand {
    	/// Request smith membership
    	Request { endpoint: String },
    	/// Emit a smith certification
    	Cert { to: u32 },
    	/// Claim smith membership
    	Claim,
    	/// Renew smith membership
    	Renew,
    	/// go online
    	GoOnline,
    	/// go offline
    	#[default]
    	GoOffline,
    	/// Rotate and set session keys
    	UpdateKeys,
    	/// set sudo keys
    	SudoSetKey { new_key: AccountId },
    	/// List upcoming expirations that require an action
    	ShowExpire {
    		/// Show certs that expire within less than this number of blocks
    		#[clap(short, long, default_value_t = 100800)]
    		blocks: u32,
    		/// Show authorities that should rotate keys within less than this number of sessions
    		#[clap(short, long, default_value_t = 100)]
    		sessions: u32,
    	},
    	/// List online authorities
    	ShowOnline,
    	/// count of smith member
    	MemberCount,
    }
    
    /// handle smith commands
    pub async fn handle_command(data: Data, command: Subcommand) -> anyhow::Result<()> {
    	let mut data = data.build_client().await?;
    	match command {
    		Subcommand::Request { endpoint } => {
    			request_smith_membership(&data, endpoint).await?;
    		}
    		Subcommand::Claim => {
    			claim_smith_membership(&data).await?;
    		}
    		Subcommand::Renew => {
    			renew_smith_membership(&data).await?;
    		}
    		Subcommand::GoOnline => {
    			go_online(&data).await?;
    		}
    		Subcommand::GoOffline => {
    			go_offline(&data).await?;
    		}
    		Subcommand::Cert { to } => {
    			data = data.fetch_idty_index().await?;
    			cert(&data, to).await?
    		}
    		Subcommand::UpdateKeys => {
    			update_session_keys(&data).await?;
    		}