fix(tree): avoid holding two locks simultaneously (#10843)

This commit is contained in:
Roman Krasiuk
2024-09-11 16:33:56 +02:00
committed by GitHub
parent 1c53518bc4
commit f6444b2e70

View File

@@ -113,10 +113,8 @@ impl InMemoryState {
/// Returns the current chain head state.
pub(crate) fn head_state(&self) -> Option<Arc<BlockState>> {
self.numbers
.read()
.last_key_value()
.and_then(|(_, hash)| self.blocks.read().get(hash).cloned())
let hash = *self.numbers.read().last_key_value()?.1;
self.state_by_hash(hash)
}
/// Returns the pending state corresponding to the current head plus one,