Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
parity
Mirrored projects
polkadot
Commits
78bc5f1d
Commit
78bc5f1d
authored
Aug 10, 2018
by
asynchronous rob
Committed by
Gav Wood
Aug 10, 2018
Browse files
fix block body fetch for availability pruning (#539)
parent
6c44c108
Changes
1
Hide whitespace changes
Inline
Side-by-side
consensus/src/service.rs
View file @
78bc5f1d
...
...
@@ -103,7 +103,8 @@ fn prune_unneeded_availability<C>(client: Arc<C>, extrinsic_store: ExtrinsicStor
use
polkadot_runtime
::
CheckedBlock
;
enum
NotifyError
{
NoBody
(::
client
::
error
::
Error
),
NoBody
,
BodyFetch
(::
client
::
error
::
Error
),
UnexpectedFormat
,
ExtrinsicsWrong
,
}
...
...
@@ -111,29 +112,34 @@ fn prune_unneeded_availability<C>(client: Arc<C>, extrinsic_store: ExtrinsicStor
impl
NotifyError
{
fn
log
(
&
self
,
hash
:
&
::
polkadot_primitives
::
Hash
)
{
match
*
self
{
NotifyError
::
NoBody
(
ref
err
)
=>
warn!
(
"Failed to fetch block body for imported block {:?}: {:?}"
,
hash
,
err
),
NotifyError
::
NoBody
=>
warn!
(
"No block body for imported block {:?}"
,
hash
),
NotifyError
::
BodyFetch
(
ref
err
)
=>
warn!
(
"Failed to fetch block body for imported block {:?}: {:?}"
,
hash
,
err
),
NotifyError
::
UnexpectedFormat
=>
warn!
(
"Consensus outdated: Block {:?} has unexpected body format"
,
hash
),
NotifyError
::
ExtrinsicsWrong
=>
warn!
(
"Consensus outdated:
Failed to fetch block body for imported block
{:?}"
,
hash
),
NotifyError
::
ExtrinsicsWrong
=>
warn!
(
"Consensus outdated:
Extrinsics cannot be decoded for
{:?}"
,
hash
),
}
}
}
client
.import_notification_stream
()
.for_each
(
move
|
notification
|
{
let
checked_block
=
client
.block_body
(
&
BlockId
::
hash
(
notification
.hash
))
.map_err
(
NotifyError
::
NoBody
)
.map
(|
b
|
::
polkadot_runtime
::
Block
::
decode
(
&
mut
b
.encode
()
.as_slice
()))
let
hash
=
notification
.hash
;
let
parent_hash
=
notification
.header.parent_hash
;
let
checked_block
=
client
.block_body
(
&
BlockId
::
hash
(
hash
))
.map_err
(
NotifyError
::
BodyFetch
)
.and_then
(|
maybe_body
|
maybe_body
.ok_or
(
NotifyError
::
NoBody
))
.map
(|
extrinsics
|
Block
{
header
:
notification
.header
,
extrinsics
})
.map
(|
b
:
Block
|
::
polkadot_runtime
::
Block
::
decode
(
&
mut
b
.encode
()
.as_slice
()))
.and_then
(|
maybe_block
|
maybe_block
.ok_or
(
NotifyError
::
UnexpectedFormat
))
.and_then
(|
block
|
CheckedBlock
::
new
(
block
)
.map_err
(|
_
|
NotifyError
::
ExtrinsicsWrong
));
match
checked_block
{
Ok
(
block
)
=>
{
let
candidate_hashes
=
block
.parachain_heads
()
.iter
()
.map
(|
c
|
c
.hash
())
.collect
();
if
let
Err
(
e
)
=
extrinsic_store
.candidates_finalized
(
notification
.header.
parent_hash
,
candidate_hashes
)
{
if
let
Err
(
e
)
=
extrinsic_store
.candidates_finalized
(
parent_hash
,
candidate_hashes
)
{
warn!
(
target
:
"consensus"
,
"Failed to prune unneeded available data: {:?}"
,
e
);
}
}
Err
(
e
)
=>
e
.log
(
&
notification
.
hash
)
Err
(
e
)
=>
e
.log
(
&
hash
)
}
Ok
(())
...
...
Write
Preview
Supports
Markdown
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!
Cancel
Please
register
or
sign in
to comment