Avoid holding write-lock whilst waiting on shuffling cache promise (#3589)

## Issue Addressed

NA

## Proposed Changes

Fixes a bug which hogged the write-lock for the `shuffling_cache`.

## Additional Info

NA
This commit is contained in:
Paul Hauner 2022-09-19 07:58:50 +00:00
parent 507bb9dad4
commit a95bcba2ab

View File

@ -4491,6 +4491,10 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
metrics::stop_timer(cache_wait_timer); metrics::stop_timer(cache_wait_timer);
if let Some(cache_item) = shuffling_cache.get(&shuffling_id) { if let Some(cache_item) = shuffling_cache.get(&shuffling_id) {
// The shuffling cache is no longer required, drop the write-lock to allow concurrent
// access.
drop(shuffling_cache);
let committee_cache = cache_item.wait()?; let committee_cache = cache_item.wait()?;
map_fn(&committee_cache, shuffling_id.shuffling_decision_block) map_fn(&committee_cache, shuffling_id.shuffling_decision_block)
} else { } else {