Trait sp_session::SessionKeys
source · pub trait SessionKeys<Block: BlockT>: Core<Block> {
fn generate_session_keys(
&self,
__runtime_api_at_param__: &BlockId<Block>,
seed: Option<Vec<u8>>
) -> Result<Vec<u8>, ApiError> { ... }
fn generate_session_keys_with_context(
&self,
__runtime_api_at_param__: &BlockId<Block>,
context: ExecutionContext,
seed: Option<Vec<u8>>
) -> Result<Vec<u8>, ApiError> { ... }
fn decode_session_keys(
&self,
__runtime_api_at_param__: &BlockId<Block>,
encoded: Vec<u8>
) -> Result<Option<Vec<(Vec<u8>, KeyTypeId)>>, ApiError> { ... }
fn decode_session_keys_with_context(
&self,
__runtime_api_at_param__: &BlockId<Block>,
context: ExecutionContext,
encoded: Vec<u8>
) -> Result<Option<Vec<(Vec<u8>, KeyTypeId)>>, ApiError> { ... }
}Expand description
Session keys runtime api.
Provided Methods§
sourcefn generate_session_keys(
&self,
__runtime_api_at_param__: &BlockId<Block>,
seed: Option<Vec<u8>>
) -> Result<Vec<u8>, ApiError>
fn generate_session_keys(
&self,
__runtime_api_at_param__: &BlockId<Block>,
seed: Option<Vec<u8>>
) -> Result<Vec<u8>, ApiError>
Generate a set of session keys with optionally using the given seed. The keys should be stored within the keystore exposed via runtime externalities.
The seed needs to be a valid utf8 string.
Returns the concatenated SCALE encoded public keys.
Examples found in repository?
src/lib.rs (line 128)
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132
pub fn generate_initial_session_keys<Block, T>(
client: std::sync::Arc<T>,
at: Block::Hash,
seeds: Vec<String>,
) -> Result<(), sp_api::ApiError>
where
Block: BlockT,
T: ProvideRuntimeApi<Block>,
T::Api: SessionKeys<Block>,
{
if seeds.is_empty() {
return Ok(())
}
let runtime_api = client.runtime_api();
for seed in seeds {
runtime_api.generate_session_keys(&BlockId::Hash(at), Some(seed.as_bytes().to_vec()))?;
}
Ok(())
}sourcefn generate_session_keys_with_context(
&self,
__runtime_api_at_param__: &BlockId<Block>,
context: ExecutionContext,
seed: Option<Vec<u8>>
) -> Result<Vec<u8>, ApiError>
fn generate_session_keys_with_context(
&self,
__runtime_api_at_param__: &BlockId<Block>,
context: ExecutionContext,
seed: Option<Vec<u8>>
) -> Result<Vec<u8>, ApiError>
Generate a set of session keys with optionally using the given seed. The keys should be stored within the keystore exposed via runtime externalities.
The seed needs to be a valid utf8 string.
Returns the concatenated SCALE encoded public keys.