Fix wasted iterations when getting previous state

This commit is contained in:
Paul Hauner 2019-09-23 22:22:19 +10:00
parent e7a580393c
commit 4fccec158a
No known key found for this signature in database
GPG Key ID: 303E4494BB28068C

View File

@ -393,7 +393,8 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
} else {
let state_root = self
.rev_iter_state_roots()
.find(|(_root, s)| *s == slot)
.take_while(|(_root, current_slot)| *current_slot >= slot)
.find(|(_root, current_slot)| *current_slot == slot)
.map(|(root, _slot)| root)
.ok_or_else(|| Error::NoStateForSlot(slot))?;