(slot_num: u64, authorities: &[AuthorityId]) -> Option<&AuthorityId
> {
+fn slot_author(slot: Slot, authorities: &[AuthorityId]) -> Option<&AuthorityId
> {
if authorities.is_empty() { return None }
- let idx = slot_num % (authorities.len() as u64);
+ let idx = *slot % (authorities.len() as u64);
assert!(
idx <= usize::max_value() as u64,
"It is impossible to have a vector with length beyond the address space; qed",
@@ -239,7 +237,7 @@ where
fn epoch_data(
&self,
header: &B::Header,
- _slot_number: u64,
+ _slot: Slot,
) -> Result {
authorities(self.client.as_ref(), &BlockId::Hash(header.hash()))
}
@@ -251,14 +249,14 @@ where
fn claim_slot(
&self,
_header: &B::Header,
- slot_number: u64,
+ slot: Slot,
epoch_data: &Self::EpochData,
) -> Option {
- let expected_author = slot_author::(slot_number, epoch_data);
+ let expected_author = slot_author::
(slot, epoch_data);
expected_author.and_then(|p| {
if SyncCryptoStore::has_keys(
- &*self.keystore,
- &[(p.to_raw_vec(), sp_application_crypto::key_types::AURA)],
+ &*self.keystore,
+ &[(p.to_raw_vec(), sp_application_crypto::key_types::AURA)],
) {
Some(p.clone())
} else {
@@ -269,11 +267,11 @@ where
fn pre_digest_data(
&self,
- slot_number: u64,
+ slot: Slot,
_claim: &Self::Claim,
) -> Vec> {
vec![
- as CompatibleDigestItem>::aura_pre_digest(slot_number),
+ as CompatibleDigestItem>::aura_pre_digest(slot),
]
}
@@ -301,6 +299,9 @@ where
header_hash.as_ref()
).map_err(|e| sp_consensus::Error::CannotSign(
public.clone(), e.to_string(),
+ ))?
+ .ok_or_else(|| sp_consensus::Error::CannotSign(
+ public.clone(), "Could not find key in keystore.".into(),
))?;
let signature = signature.clone().try_into()
.map_err(|_| sp_consensus::Error::InvalidSignature(
@@ -323,14 +324,14 @@ where
self.force_authoring
}
- fn should_backoff(&self, slot_number: u64, chain_head: &B::Header) -> bool {
+ fn should_backoff(&self, slot: Slot, chain_head: &B::Header) -> bool {
if let Some(ref strategy) = self.backoff_authoring_blocks {
if let Ok(chain_head_slot) = find_pre_digest::(chain_head) {
return strategy.should_backoff(
*chain_head.number(),
chain_head_slot,
self.client.info().finalized_number,
- slot_number,
+ slot,
self.logging_target(),
);
}
@@ -363,9 +364,10 @@ where
if let Some(slot_lenience) =
sc_consensus_slots::slot_lenience_exponential(parent_slot, slot_info)
{
- debug!(target: "aura",
+ debug!(
+ target: "aura",
"No block for {} slots. Applying linear lenience of {}s",
- slot_info.number.saturating_sub(parent_slot + 1),
+ slot_info.slot.saturating_sub(parent_slot + 1),
slot_lenience.as_secs(),
);
@@ -401,7 +403,7 @@ enum Error {
DataProvider(String),
Runtime(String),
#[display(fmt = "Slot number must increase: parent slot: {}, this slot: {}", _0, _1)]
- SlotNumberMustIncrease(u64, u64),
+ SlotMustIncrease(Slot, Slot),
#[display(fmt = "Parent ({}) of {} unavailable. Cannot import", _0, _1)]
ParentUnavailable(B::Hash, B::Hash),
}
@@ -412,16 +414,16 @@ impl std::convert::From> for String {
}
}
-fn find_pre_digest