Skip to content
Snippets Groups Projects
Select Git revision
  • 079fa58f2ac5df7b38e74a989bcf76b279e50eb5
  • master default protected
  • network/gdev-800 protected
  • cgeek/issue-297-cpu
  • gdev-800-tests
  • update-docker-compose-rpc-squid-names
  • fix-252
  • 1000i100-test
  • hugo/tmp-0.9.1
  • network/gdev-803 protected
  • hugo/endpoint-gossip
  • network/gdev-802 protected
  • hugo/distance-precompute
  • network/gdev-900 protected
  • tuxmain/anonymous-tx
  • debug/podman
  • hugo/195-doc
  • hugo/195-graphql-schema
  • hugo-tmp-dockerfile-cache
  • release/client-800.2 protected
  • release/runtime-800 protected
  • gdev-900-0.10.1 protected
  • gdev-900-0.10.0 protected
  • gdev-900-0.9.2 protected
  • gdev-800-0.8.0 protected
  • gdev-900-0.9.1 protected
  • gdev-900-0.9.0 protected
  • gdev-803 protected
  • gdev-802 protected
  • runtime-801 protected
  • gdev-800 protected
  • runtime-800-bis protected
  • runtime-800 protected
  • runtime-800-backup protected
  • runtime-701 protected
  • runtime-700 protected
  • runtime-600 protected
  • runtime-500 protected
  • v0.4.1 protected
  • runtime-401 protected
  • v0.4.0 protected
41 results

replay-block.md

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?;
    		}