mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-09 19:01:08 +00:00
Merge remote-tracking branch 'origin/master' into staking
This commit is contained in:
+10
-8
@@ -218,8 +218,8 @@ pub struct SubxtClientConfig<C: ChainSpec + 'static> {
|
||||
pub chain_spec: C,
|
||||
/// Role of the node.
|
||||
pub role: Role,
|
||||
/// Enable telemetry.
|
||||
pub enable_telemetry: bool,
|
||||
/// Enable telemetry on the given port.
|
||||
pub telemetry: Option<u16>,
|
||||
}
|
||||
|
||||
impl<C: ChainSpec + 'static> SubxtClientConfig<C> {
|
||||
@@ -238,10 +238,12 @@ impl<C: ChainSpec + 'static> SubxtClientConfig<C> {
|
||||
wasm_external_transport: None,
|
||||
use_yamux_flow_control: true,
|
||||
};
|
||||
let telemetry_endpoints = if self.enable_telemetry {
|
||||
let endpoints =
|
||||
TelemetryEndpoints::new(vec![("/ip4/127.0.0.1/tcp/99000/ws".into(), 0)])
|
||||
.expect("valid config; qed");
|
||||
let telemetry_endpoints = if let Some(port) = self.telemetry {
|
||||
let endpoints = TelemetryEndpoints::new(vec![(
|
||||
format!("/ip4/127.0.0.1/tcp/{}/ws", port),
|
||||
0,
|
||||
)])
|
||||
.expect("valid config; qed");
|
||||
Some(endpoints)
|
||||
} else {
|
||||
None
|
||||
@@ -356,7 +358,7 @@ mod tests {
|
||||
keystore: KeystoreConfig::InMemory,
|
||||
chain_spec,
|
||||
role: Role::Light,
|
||||
enable_telemetry: false,
|
||||
telemetry: None,
|
||||
};
|
||||
let client = ClientBuilder::<NodeTemplateRuntime>::new()
|
||||
.set_client(
|
||||
@@ -389,7 +391,7 @@ mod tests {
|
||||
keystore: KeystoreConfig::InMemory,
|
||||
chain_spec: test_node::chain_spec::development_config().unwrap(),
|
||||
role: Role::Authority(AccountKeyring::Alice),
|
||||
enable_telemetry: false,
|
||||
telemetry: None,
|
||||
};
|
||||
let client = ClientBuilder::<NodeTemplateRuntime>::new()
|
||||
.set_client(
|
||||
|
||||
@@ -307,9 +307,11 @@ pub struct NominateCall<T: Staking> {
|
||||
pub targets: Vec<T::Address>,
|
||||
}
|
||||
|
||||
/// Claim a payout.
|
||||
/// Claim a payout for a validator’s stakers
|
||||
#[derive(PartialEq, Eq, Clone, Call, Encode, Decode, Debug)]
|
||||
pub struct PayoutStakersCall<'a, T: Staking> {
|
||||
/// Stash account of the validator
|
||||
pub validator_stash: &'a T::AccountId,
|
||||
/// Era index
|
||||
pub era: EraIndex,
|
||||
}
|
||||
|
||||
+17
-8
@@ -247,7 +247,7 @@ impl<T: Runtime, F: Store<T>> KeyIter<T, F> {
|
||||
}
|
||||
}
|
||||
}
|
||||
debug_assert_eq!(self.buffer.len(), self.count as usize);
|
||||
debug_assert_eq!(self.buffer.len(), keys.len());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -269,6 +269,19 @@ impl<T: Runtime> Client<T> {
|
||||
&self.properties
|
||||
}
|
||||
|
||||
/// Fetch the value under an unhashed storage key
|
||||
pub async fn fetch_unhashed<V: Decode>(
|
||||
&self,
|
||||
key: StorageKey,
|
||||
hash: Option<T::Hash>,
|
||||
) -> Result<Option<V>, Error> {
|
||||
if let Some(data) = self.rpc.storage(&key, hash).await? {
|
||||
Ok(Some(Decode::decode(&mut &data.0[..])?))
|
||||
} else {
|
||||
Ok(None)
|
||||
}
|
||||
}
|
||||
|
||||
/// Fetch a StorageKey with an optional block hash.
|
||||
pub async fn fetch<F: Store<T>>(
|
||||
&self,
|
||||
@@ -276,11 +289,7 @@ impl<T: Runtime> Client<T> {
|
||||
hash: Option<T::Hash>,
|
||||
) -> Result<Option<F::Returns>, Error> {
|
||||
let key = store.key(&self.metadata)?;
|
||||
if let Some(data) = self.rpc.storage(&key, hash).await? {
|
||||
Ok(Some(Decode::decode(&mut &data.0[..])?))
|
||||
} else {
|
||||
Ok(None)
|
||||
}
|
||||
self.fetch_unhashed::<F::Returns>(key, hash).await
|
||||
}
|
||||
|
||||
/// Fetch a StorageKey that has a default value with an optional block hash.
|
||||
@@ -599,14 +608,14 @@ mod tests {
|
||||
},
|
||||
chain_spec: test_node::chain_spec::development_config().unwrap(),
|
||||
role: Role::Authority(key),
|
||||
enable_telemetry: false,
|
||||
telemetry: None,
|
||||
};
|
||||
let client = ClientBuilder::new()
|
||||
.set_client(
|
||||
SubxtClient::from_config(config, test_node::service::new_full)
|
||||
.expect("Error creating subxt client"),
|
||||
)
|
||||
.set_page_size(2)
|
||||
.set_page_size(3)
|
||||
.build()
|
||||
.await
|
||||
.expect("Error creating client");
|
||||
|
||||
Reference in New Issue
Block a user