1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#![cfg_attr(not(feature = "std"), no_std)]
use codec::{Encode, Decode, Codec};
use sp_std::vec::Vec;
use sp_runtime::ConsensusEngineId;
pub mod digests;
pub mod inherents;
pub mod sr25519 {
mod app_sr25519 {
use sp_application_crypto::{app_crypto, key_types::AURA, sr25519};
app_crypto!(sr25519, AURA);
}
sp_application_crypto::with_pair! {
pub type AuthorityPair = app_sr25519::Pair;
}
pub type AuthoritySignature = app_sr25519::Signature;
pub type AuthorityId = app_sr25519::Public;
}
pub mod ed25519 {
mod app_ed25519 {
use sp_application_crypto::{app_crypto, key_types::AURA, ed25519};
app_crypto!(ed25519, AURA);
}
sp_application_crypto::with_pair! {
pub type AuthorityPair = app_ed25519::Pair;
}
pub type AuthoritySignature = app_ed25519::Signature;
pub type AuthorityId = app_ed25519::Public;
}
pub use sp_consensus_slots::Slot;
pub const AURA_ENGINE_ID: ConsensusEngineId = [b'a', b'u', b'r', b'a'];
pub type AuthorityIndex = u32;
#[derive(Decode, Encode)]
pub enum ConsensusLog<AuthorityId: Codec> {
#[codec(index = 1)]
AuthoritiesChange(Vec<AuthorityId>),
#[codec(index = 2)]
OnDisabled(AuthorityIndex),
}
sp_api::decl_runtime_apis! {
pub trait AuraApi<AuthorityId: Codec> {
fn slot_duration() -> SlotDuration;
fn authorities() -> Vec<AuthorityId>;
}
}
#[derive(sp_runtime::RuntimeDebug, Encode, Decode, PartialEq, Clone, Copy)]
pub struct SlotDuration(u64);
impl SlotDuration {
pub fn from_millis(val: u64) -> Self {
Self(val)
}
pub fn get(&self) -> u64 {
self.0
}
}
#[cfg(feature = "std")]
impl sp_consensus::SlotData for SlotDuration {
fn slot_duration(&self) -> std::time::Duration {
std::time::Duration::from_millis(self.0)
}
const SLOT_KEY: &'static [u8] = b"aura_slot_duration";
}