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
e33a8dde
Commit
e33a8dde
authored
6 years ago
by
asynchronous rob
Browse files
Options
Downloads
Patches
Plain Diff
compiles
parent
5f6dc6bc
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
substrate/core/finality-grandpa/src/authorities.rs
+20
-11
20 additions, 11 deletions
substrate/core/finality-grandpa/src/authorities.rs
substrate/core/finality-grandpa/src/lib.rs
+7
-7
7 additions, 7 deletions
substrate/core/finality-grandpa/src/lib.rs
with
27 additions
and
18 deletions
substrate/core/finality-grandpa/src/authorities.rs
+
20
−
11
View file @
e33a8dde
...
...
@@ -20,6 +20,7 @@ use parking_lot::RwLock;
use
substrate_primitives
::
AuthorityId
;
use
std
::
cmp
::
Ord
;
use
std
::
fmt
::
Debug
;
use
std
::
ops
::
Add
;
use
std
::
sync
::
Arc
;
...
...
@@ -54,14 +55,19 @@ impl<H, N> SharedAuthoritySet<H, N> {
}
}
impl
<
H
:
Eq
,
N
:
Add
<
Output
=
N
>
+
Ord
+
Clone
>
SharedAuthoritySet
<
H
,
N
>
{
impl
<
H
:
Eq
,
N
>
SharedAuthoritySet
<
H
,
N
>
where
N
:
Add
<
Output
=
N
>
+
Ord
+
Clone
+
Debug
{
/// Note an upcoming pending transition.
pub
(
crate
)
fn
add_pending_change
(
&
self
,
pending
:
PendingChange
<
H
,
N
>
)
{
// ordered first by effective number and then by signal-block number.
let
mut
inner
=
self
.inner
.write
();
let
key
=
(
pending
.effective_number
(),
pending
.canon_height
);
let
key
=
(
pending
.effective_number
(),
pending
.canon_height
.clone
()
);
let
idx
=
inner
.pending_changes
.binary_search_by_key
(
&
key
,
|
change
|
(
change
.effective_number
(),
change
.canon_height
))
.binary_search_by_key
(
&
key
,
|
change
|
(
change
.effective_number
(),
change
.canon_height
.clone
(),
))
.unwrap_or_else
(|
i
|
i
);
inner
.pending_changes
.insert
(
idx
,
pending
);
...
...
@@ -98,11 +104,6 @@ pub(crate) struct AuthoritySet<H, N> {
}
impl
<
H
,
N
>
AuthoritySet
<
H
,
N
>
{
/// Get the earliest limit-block number, if any.
pub
(
crate
)
fn
current_limit
(
&
self
)
->
Option
<
N
>
{
self
.pending_changes
.get
(
0
)
.map
(|
change
|
change
.effective_number
()
.clone
())
}
/// Get the set identifier.
pub
(
crate
)
fn
set_id
(
&
self
)
->
u64
{
self
.set_id
...
...
@@ -114,12 +115,20 @@ impl<H, N> AuthoritySet<H, N> {
}
}
impl
<
H
:
Eq
,
N
:
Ord
+
Debug
>
AuthoritySet
<
H
,
N
>
{
impl
<
H
:
Eq
,
N
>
AuthoritySet
<
H
,
N
>
where
N
:
Add
<
Output
=
N
>
+
Ord
+
Clone
+
Debug
,
{
/// Get the earliest limit-block number, if any.
pub
(
crate
)
fn
current_limit
(
&
self
)
->
Option
<
N
>
{
self
.pending_changes
.get
(
0
)
.map
(|
change
|
change
.effective_number
()
.clone
())
}
/// Apply or prune any pending transitions. Provide a closure that can be used to check for the
/// finalized block with given number.
///
/// Returns true when the set's representation has changed.
pub
(
crate
)
fn
apply_changes
<
F
,
E
>
(
&
mut
self
,
just_finalized
:
N
,
canonical
:
F
)
->
Result
<
bool
,
E
>
pub
(
crate
)
fn
apply_changes
<
F
,
E
>
(
&
mut
self
,
just_finalized
:
N
,
mut
canonical
:
F
)
->
Result
<
bool
,
E
>
where
F
:
FnMut
(
N
)
->
Result
<
H
,
E
>
{
let
mut
changed
=
false
;
...
...
@@ -132,7 +141,7 @@ impl<H: Eq, N: Ord + Debug> AuthoritySet<H, N> {
// check if the block that signalled the change is canonical in
// our chain.
if
canonical
(
change
.canon_height
)
?
==
change
.canon_hash
{
if
canonical
(
change
.canon_height
.clone
()
)
?
==
change
.canon_hash
{
// apply this change: make the set canonical
info!
(
target
:
"finality"
,
"Applying authority set change scheduled at block #{:?}"
,
change
.canon_height
);
...
...
This diff is collapsed.
Click to expand it.
substrate/core/finality-grandpa/src/lib.rs
+
7
−
7
View file @
e33a8dde
...
...
@@ -108,7 +108,7 @@ pub enum Error {
/// A blockchain error.
Blockchain
(
String
),
/// Could not complete a round on disk.
C
ouldNotCompleteRound
(
ClientError
),
C
lient
(
ClientError
),
/// A timer failed to fire.
Timer
(::
tokio
::
timer
::
Error
),
}
...
...
@@ -520,7 +520,7 @@ impl From<Error> for ExitOrError {
impl
From
<
ClientError
>
for
ExitOrError
{
fn
from
(
e
:
ClientError
)
->
Self
{
ExitOrError
::
Error
(
Error
::
from
(
e
))
ExitOrError
::
Error
(
Error
::
Client
(
e
))
}
}
...
...
@@ -578,7 +578,7 @@ impl<B, E, Block: BlockT, N> voter::Environment<Block::Hash, NumberFor<Block>> f
self
.config.local_key
.clone
(),
self
.config.genesis_voters
.clone
(),
self
.network
.clone
(),
)
.sink_map_err
(
Into
::
into
);
);
// schedule incoming messages from the network to be held until
// corresponding blocks are imported.
...
...
@@ -595,12 +595,12 @@ impl<B, E, Block: BlockT, N> voter::Environment<Block::Hash, NumberFor<Block>> f
let
outgoing
=
Box
::
new
(
ClearOnDrop
{
round
,
network
:
self
.network
.clone
(),
inner
:
outgoing
,
inner
:
outgoing
.sink_map_err
(
Into
::
into
)
,
});
voter
::
RoundData
{
prevote_timer
:
Box
::
new
(
prevote_timer
.map_err
(
Error
::
Timer
)),
precommit_timer
:
Box
::
new
(
precommit_timer
.map_err
(
Error
::
Timer
)),
prevote_timer
:
Box
::
new
(
prevote_timer
.map_err
(
|
e
|
Error
::
Timer
(
e
)
.into
()
)),
precommit_timer
:
Box
::
new
(
precommit_timer
.map_err
(
|
e
|
Error
::
Timer
(
e
)
.into
()
)),
voters
:
self
.voters
.clone
(),
incoming
,
outgoing
,
...
...
@@ -613,7 +613,7 @@ impl<B, E, Block: BlockT, N> voter::Environment<Block::Hash, NumberFor<Block>> f
.insert_aux
(
&
[(
LAST_COMPLETED_KEY
,
&
encoded_state
[
..
])],
&
[])
{
warn!
(
target
:
"afg"
,
"Shutting down voter due to error bookkeeping last completed round in DB: {:?}"
,
e
);
Err
(
Error
::
C
ouldNotCompleteRound
(
e
)
.into
())
Err
(
Error
::
C
lient
(
e
)
.into
())
}
else
{
Ok
(())
}
...
...
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