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
99734323
Commit
99734323
authored
5 years ago
by
asynchronous rob
Committed by
Gavin Wood
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
back-off block proposal (#4235)
parent
4598e130
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
substrate/client/consensus/babe/src/lib.rs
+26
-0
26 additions, 0 deletions
substrate/client/consensus/babe/src/lib.rs
with
26 additions
and
0 deletions
substrate/client/consensus/babe/src/lib.rs
+
26
−
0
View file @
99734323
...
...
@@ -453,6 +453,32 @@ impl<B, C, E, I, Error, SO> slots::SimpleSlotWorker<B> for BabeWorker<B, C, E, I
consensus_common
::
Error
::
ClientImport
(
format!
(
"{:?}"
,
e
))
})
}
fn
proposing_remaining_duration
(
&
self
,
head
:
&
B
::
Header
,
slot_info
:
&
SlotInfo
)
->
Option
<
std
::
time
::
Duration
>
{
// never give more than 20 times more lenience.
const
BACKOFF_CAP
:
u64
=
20
;
let
slot_remaining
=
self
.slot_remaining_duration
(
slot_info
);
let
parent_slot
=
match
find_pre_digest
::
<
B
>
(
head
)
{
Err
(
_
)
=>
return
Some
(
slot_remaining
),
Ok
(
d
)
=>
d
.slot_number
(),
};
// we allow a lenience of the number of slots since the head of the
// chain was produced, minus 1 (since there is always a difference of at least 1)
//
// linear back-off.
// in normal cases we only attempt to issue blocks up to the end of the slot.
// when the chain has been stalled for a few slots, we give more lenience.
let
slot_lenience
=
slot_info
.number
.saturating_sub
(
parent_slot
+
1
);
let
slot_lenience
=
std
::
cmp
::
min
(
slot_lenience
,
BACKOFF_CAP
);
let
slot_lenience
=
Duration
::
from_secs
(
slot_lenience
*
slot_info
.duration
);
Some
(
slot_lenience
+
slot_remaining
)
}
}
impl
<
B
,
C
,
E
,
I
,
Error
,
SO
>
SlotWorker
<
B
>
for
BabeWorker
<
B
,
C
,
E
,
I
,
SO
>
where
...
...
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