fix race in light_peer_imports_header_from_announce (#4579)

This commit is contained in:
Svyatoslav Nikolsky
2020-01-10 01:28:04 +03:00
committed by Gavin Wood
parent bc3d283e78
commit f372fa4d72
6 changed files with 76 additions and 29 deletions
+4 -2
View File
@@ -433,18 +433,20 @@ impl<Block: BlockT> sc_client_api::light::Storage<Block> for Blockchain<Block>
&self,
_cht_size: NumberFor<Block>,
block: NumberFor<Block>,
) -> sp_blockchain::Result<Block::Hash> {
) -> sp_blockchain::Result<Option<Block::Hash>> {
self.storage.read().header_cht_roots.get(&block).cloned()
.ok_or_else(|| sp_blockchain::Error::Backend(format!("Header CHT for block {} not exists", block)))
.map(Some)
}
fn changes_trie_cht_root(
&self,
_cht_size: NumberFor<Block>,
block: NumberFor<Block>,
) -> sp_blockchain::Result<Block::Hash> {
) -> sp_blockchain::Result<Option<Block::Hash>> {
self.storage.read().changes_trie_cht_roots.get(&block).cloned()
.ok_or_else(|| sp_blockchain::Error::Backend(format!("Changes trie CHT for block {} not exists", block)))
.map(Some)
}
fn cache(&self) -> Option<Arc<dyn blockchain::Cache<Block>>> {