Storage chains sync (#9171)

* Sync storage chains

* Test

* Apply suggestions from code review

Co-authored-by: cheme <emericchevalier.pro@gmail.com>

* Separate block body and indexed body

* Update client/db/src/lib.rs

Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com>

Co-authored-by: cheme <emericchevalier.pro@gmail.com>
Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com>
This commit is contained in:
Arkadiy Paronyan
2021-07-17 10:58:37 +02:00
committed by GitHub
parent f07a41e87d
commit 5a65bf5515
27 changed files with 221 additions and 59 deletions
@@ -264,6 +264,7 @@ impl<B: BlockT> BlockRequestHandler<B> {
) -> Result<BlockResponse, HandleRequestError> {
let get_header = attributes.contains(BlockAttributes::HEADER);
let get_body = attributes.contains(BlockAttributes::BODY);
let get_indexed_body = attributes.contains(BlockAttributes::INDEXED_BODY);
let get_justification = attributes.contains(BlockAttributes::JUSTIFICATION);
let mut blocks = Vec::new();
@@ -321,6 +322,18 @@ impl<B: BlockT> BlockRequestHandler<B> {
Vec::new()
};
let indexed_body = if get_indexed_body {
match self.client.block_indexed_body(&BlockId::Hash(hash))? {
Some(transactions) => transactions,
None => {
log::trace!(target: LOG_TARGET, "Missing indexed block data for block request.");
break;
}
}
} else {
Vec::new()
};
let block_data = crate::schema::v1::BlockData {
hash: hash.encode(),
header: if get_header {
@@ -334,6 +347,7 @@ impl<B: BlockT> BlockRequestHandler<B> {
justification,
is_empty_justification,
justifications,
indexed_body,
};
total_size += block_data.body.len();