Skip to content

Commit 2076040

Browse files
committed
State access refactor
1 parent 01a2fd2 commit 2076040

File tree

1 file changed

+10
-16
lines changed
  • anchor/validator_store/src

1 file changed

+10
-16
lines changed

anchor/validator_store/src/lib.rs

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -589,19 +589,6 @@ impl<T: SlotClock, E: EthSpec> AnchorValidatorStore<T, E> {
589589
})
590590
.collect::<HashMap<_, _>>()
591591
}
592-
593-
fn is_cluster_active(&self, validator_pubkey: &PublicKeyBytes) -> bool {
594-
let state = self.database.state();
595-
596-
if let Some(validator) = state.metadata().get_by(validator_pubkey)
597-
&& let Some(cluster) = state.clusters().get_by(&validator.cluster_id)
598-
{
599-
return !cluster.liquidated;
600-
}
601-
602-
// We did not manage to fetch the cluster
603-
false
604-
}
605592
}
606593

607594
/// # Arguments
@@ -809,13 +796,20 @@ impl<T: SlotClock, E: EthSpec> ValidatorStore for AnchorValidatorStore<T, E> {
809796
I: FromIterator<PublicKeyBytes>,
810797
F: Fn(DoppelgangerStatus) -> Option<PublicKeyBytes>,
811798
{
799+
let state = self.database.state();
800+
let clusters = state.clusters();
801+
812802
// Treat all shares as `SigningEnabled`
813-
self.database
814-
.state()
803+
state
815804
.shares()
816805
.values()
817806
.filter_map(|v| filter_func(DoppelgangerStatus::SigningEnabled(v.validator_pubkey)))
818-
.filter(|public_key| self.is_cluster_active(public_key))
807+
.filter(|public_key| {
808+
if let Some(clusters) = clusters.get_by(public_key) {
809+
return !clusters.liquidated;
810+
}
811+
false
812+
})
819813
.collect()
820814
}
821815

0 commit comments

Comments
 (0)