Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Prev Previous commit
Next Next commit
srml/authority-discovery: Fix line length
  • Loading branch information
mxinden committed Sep 26, 2019
commit 2181d2c7984e20fde1df65016d723bd0c8eba5b7
17 changes: 13 additions & 4 deletions srml/authority-discovery/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@
#![cfg_attr(not(feature = "std"), no_std)]

use app_crypto::RuntimeAppPublic;
use codec::{Decode, Encode};
use rstd::prelude::*;
use support::{decl_module, decl_storage};
use codec::{Decode, Encode};

pub trait Trait: system::Trait + session::Trait {
type AuthorityId: RuntimeAppPublic + Default + Decode + Encode + PartialEq;
type AuthorityId: RuntimeAppPublic + Default + Decode + Encode + PartialEq;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needs docs

}

decl_storage! {
Expand Down Expand Up @@ -78,7 +78,12 @@ impl<T: Trait> Module<T> {
}

/// Sign the given payload with the private key corresponding to the given authority id.
pub fn sign(payload: &Vec<u8>) -> Option<(<<T as Trait>::AuthorityId as RuntimeAppPublic>::Signature, T::AuthorityId)> {
pub fn sign(
payload: &Vec<u8>,
) -> Option<(
<<T as Trait>::AuthorityId as RuntimeAppPublic>::Signature,
T::AuthorityId,
)> {
let authority_id = Module::<T>::authority_id()?;
authority_id.sign(payload).map(|s| (s, authority_id))
}
Expand Down Expand Up @@ -336,7 +341,11 @@ mod tests {
let payload = String::from("test payload").into_bytes();
let (sig, authority_id) = AuthorityDiscovery::sign(&payload).expect("signature");

assert!(AuthorityDiscovery::verify(&payload, sig.clone(), authority_id.clone(),));
assert!(AuthorityDiscovery::verify(
&payload,
sig.clone(),
authority_id.clone(),
));

assert!(!AuthorityDiscovery::verify(
&String::from("other payload").into_bytes(),
Expand Down