Block::decode() returns Result (#8586)
This commit is contained in:
parent
ecd7caa93d
commit
61ec02248a
@ -206,7 +206,7 @@ impl Block {
|
|||||||
pub fn header_view(&self) -> HeaderView { self.view().header_view() }
|
pub fn header_view(&self) -> HeaderView { self.view().header_view() }
|
||||||
|
|
||||||
/// Decode to a full block.
|
/// Decode to a full block.
|
||||||
pub fn decode(&self) -> FullBlock { ::rlp::decode(&self.0).expect("decoding failure") }
|
pub fn decode(&self) -> Result<FullBlock, rlp::DecoderError> { rlp::decode(&self.0) }
|
||||||
|
|
||||||
/// Decode the header.
|
/// Decode the header.
|
||||||
pub fn decode_header(&self) -> FullHeader { self.view().rlp().val_at(0) }
|
pub fn decode_header(&self) -> FullHeader { self.view().rlp().val_at(0) }
|
||||||
|
@ -100,7 +100,7 @@ impl SnapshotComponents for PoaSnapshot {
|
|||||||
let (block, receipts) = chain.block(&block_at)
|
let (block, receipts) = chain.block(&block_at)
|
||||||
.and_then(|b| chain.block_receipts(&block_at).map(|r| (b, r)))
|
.and_then(|b| chain.block_receipts(&block_at).map(|r| (b, r)))
|
||||||
.ok_or(Error::BlockNotFound(block_at))?;
|
.ok_or(Error::BlockNotFound(block_at))?;
|
||||||
let block = block.decode();
|
let block = block.decode()?;
|
||||||
|
|
||||||
let parent_td = chain.block_details(block.header.parent_hash())
|
let parent_td = chain.block_details(block.header.parent_hash())
|
||||||
.map(|d| d.total_difficulty)
|
.map(|d| d.total_difficulty)
|
||||||
|
Loading…
Reference in New Issue
Block a user