Simplify the code a little bit (#8295)

This commit is contained in:
Liu-Cheng Xu
2021-03-09 22:51:11 +08:00
committed by GitHub
parent 85f32e8813
commit ed7e485365
@@ -139,7 +139,7 @@ fn claim_secondary_slot(
return None; return None;
} }
let expected_author = super::authorship::secondary_slot_author( let expected_author = secondary_slot_author(
slot, slot,
authorities, authorities,
*randomness, *randomness,
@@ -148,7 +148,7 @@ fn claim_secondary_slot(
for (authority_id, authority_index) in keys { for (authority_id, authority_index) in keys {
if authority_id == expected_author { if authority_id == expected_author {
let pre_digest = if author_secondary_vrf { let pre_digest = if author_secondary_vrf {
let transcript_data = super::authorship::make_transcript_data( let transcript_data = make_transcript_data(
randomness, randomness,
slot, slot,
*epoch_index, *epoch_index,
@@ -243,12 +243,12 @@ fn claim_primary_slot(
let Epoch { authorities, randomness, epoch_index, .. } = epoch; let Epoch { authorities, randomness, epoch_index, .. } = epoch;
for (authority_id, authority_index) in keys { for (authority_id, authority_index) in keys {
let transcript = super::authorship::make_transcript( let transcript = make_transcript(
randomness, randomness,
slot, slot,
*epoch_index *epoch_index
); );
let transcript_data = super::authorship::make_transcript_data( let transcript_data = make_transcript_data(
randomness, randomness,
slot, slot,
*epoch_index *epoch_index
@@ -257,7 +257,7 @@ fn claim_primary_slot(
// //
// We already checked that authorities contains `key.public()`, so it can't // We already checked that authorities contains `key.public()`, so it can't
// be empty. Therefore, this division in `calculate_threshold` is safe. // be empty. Therefore, this division in `calculate_threshold` is safe.
let threshold = super::authorship::calculate_primary_threshold(c, authorities, *authority_index); let threshold = calculate_primary_threshold(c, authorities, *authority_index);
let result = SyncCryptoStore::sr25519_vrf_sign( let result = SyncCryptoStore::sr25519_vrf_sign(
&**keystore, &**keystore,
@@ -271,7 +271,7 @@ fn claim_primary_slot(
Ok(inout) => inout, Ok(inout) => inout,
Err(_) => continue, Err(_) => continue,
}; };
if super::authorship::check_primary_threshold(&inout, threshold) { if check_primary_threshold(&inout, threshold) {
let pre_digest = PreDigest::Primary(PrimaryPreDigest { let pre_digest = PreDigest::Primary(PrimaryPreDigest {
slot, slot,
vrf_output: VRFOutput(signature.output), vrf_output: VRFOutput(signature.output),