Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
polkadot-sdk
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
parity
Mirrored projects
polkadot-sdk
Commits
310987ab
Commit
310987ab
authored
5 years ago
by
Bastian Köcher
Committed by
GitHub
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Implements `FindAuthor<u32>` for `srml-aura` (#3426)
* Implements `FindAuthor<u32>` for `srml-aura` * Update lib.rs * Build
parent
a0f2e9b3
Branches
Branches containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
substrate/core/consensus/aura/primitives/src/lib.rs
+1
-1
1 addition, 1 deletion
substrate/core/consensus/aura/primitives/src/lib.rs
substrate/srml/aura/src/lib.rs
+24
-6
24 additions, 6 deletions
substrate/srml/aura/src/lib.rs
with
25 additions
and
7 deletions
substrate/core/consensus/aura/primitives/src/lib.rs
+
1
−
1
View file @
310987ab
...
...
@@ -61,7 +61,7 @@ pub mod ed25519 {
pub
const
AURA_ENGINE_ID
:
ConsensusEngineId
=
[
b'a'
,
b'u'
,
b'r'
,
b'a'
];
/// The index of an authority.
pub
type
AuthorityIndex
=
u
64
;
pub
type
AuthorityIndex
=
u
32
;
/// An consensus log item for Aura.
#[derive(Decode,
Encode)]
...
...
This diff is collapsed.
Click to expand it.
substrate/srml/aura/src/lib.rs
+
24
−
6
View file @
310987ab
...
...
@@ -48,8 +48,11 @@
pub
use
timestamp
;
use
rstd
::{
result
,
prelude
::
*
};
use
codec
::
Encode
;
use
srml_support
::{
decl_storage
,
decl_module
,
Parameter
,
storage
::
StorageValue
,
traits
::
Get
};
use
codec
::{
Encode
,
Decode
};
use
srml_support
::{
decl_storage
,
decl_module
,
Parameter
,
storage
::
StorageValue
,
traits
::{
Get
,
FindAuthor
},
ConsensusEngineId
,
};
use
app_crypto
::
AppPublic
;
use
sr_primitives
::{
traits
::{
SaturatedConversion
,
Saturating
,
Zero
,
Member
,
IsMember
},
generic
::
DigestItem
,
...
...
@@ -60,9 +63,7 @@ use timestamp::TimestampInherentData;
use
inherents
::{
RuntimeString
,
InherentIdentifier
,
InherentData
,
ProvideInherent
,
MakeFatalError
};
#[cfg(feature
=
"std"
)]
use
inherents
::{
InherentDataProviders
,
ProvideInherentData
};
use
substrate_consensus_aura_primitives
::{
AURA_ENGINE_ID
,
ConsensusLog
};
#[cfg(feature
=
"std"
)]
use
codec
::
Decode
;
use
substrate_consensus_aura_primitives
::{
AURA_ENGINE_ID
,
ConsensusLog
,
AuthorityIndex
};
mod
mock
;
mod
tests
;
...
...
@@ -215,13 +216,30 @@ impl<T: Trait> session::OneSessionHandler<T::AccountId> for Module<T> {
fn
on_disabled
(
i
:
usize
)
{
let
log
:
DigestItem
<
T
::
Hash
>
=
DigestItem
::
Consensus
(
AURA_ENGINE_ID
,
ConsensusLog
::
<
T
::
AuthorityId
>
::
OnDisabled
(
i
as
u64
)
.encode
(),
ConsensusLog
::
<
T
::
AuthorityId
>
::
OnDisabled
(
i
as
AuthorityIndex
)
.encode
(),
);
<
system
::
Module
<
T
>>
::
deposit_log
(
log
.into
());
}
}
impl
<
T
:
Trait
>
FindAuthor
<
u32
>
for
Module
<
T
>
{
fn
find_author
<
'a
,
I
>
(
digests
:
I
)
->
Option
<
u32
>
where
I
:
'a
+
IntoIterator
<
Item
=
(
ConsensusEngineId
,
&
'a
[
u8
])
>
{
for
(
id
,
mut
data
)
in
digests
.into_iter
()
{
if
id
==
AURA_ENGINE_ID
{
if
let
Ok
(
slot_num
)
=
u64
::
decode
(
&
mut
data
)
{
let
author_index
=
slot_num
%
Self
::
authorities
()
.len
()
as
u64
;
return
Some
(
author_index
as
u32
)
}
}
}
None
}
}
impl
<
T
:
Trait
>
IsMember
<
T
::
AuthorityId
>
for
Module
<
T
>
{
fn
is_member
(
authority_id
:
&
T
::
AuthorityId
)
->
bool
{
Self
::
authorities
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment