Merge remote-tracking branch 'origin/master' into staking

This commit is contained in:
Demi M. Obenour
2020-08-24 13:36:10 -04:00
3 changed files with 30 additions and 17 deletions
+3 -1
View File
@@ -307,9 +307,11 @@ pub struct NominateCall<T: Staking> {
pub targets: Vec<T::Address>,
}
/// Claim a payout.
/// Claim a payout for a validators 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
View File
@@ -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");