Remove iter mod from beacon chain

Now the iter mod in store is the only implementation
This commit is contained in:
Paul Hauner
2019-06-19 02:06:23 +10:00
parent 952e08ba38
commit 55196dff64
5 changed files with 36 additions and 139 deletions

View File

@@ -11,7 +11,6 @@ pub struct StateRootsIterator<'a, T: EthSpec, U> {
}
impl<'a, T: EthSpec, U: Store> StateRootsIterator<'a, T, U> {
/// Create a new iterator over all blocks in the given `beacon_state` and prior states.
pub fn new(store: Arc<U>, beacon_state: &'a BeaconState<T>, start_slot: Slot) -> Self {
Self {
store,
@@ -19,6 +18,14 @@ impl<'a, T: EthSpec, U: Store> StateRootsIterator<'a, T, U> {
slot: start_slot,
}
}
pub fn owned(store: Arc<U>, beacon_state: BeaconState<T>, start_slot: Slot) -> Self {
Self {
slot: start_slot,
beacon_state: Cow::Owned(beacon_state),
store,
}
}
}
impl<'a, T: EthSpec, U: Store> Iterator for StateRootsIterator<'a, T, U> {
@@ -65,6 +72,13 @@ impl<'a, T: EthSpec, U: Store> BlockIterator<'a, T, U> {
roots: BlockRootsIterator::new(store, beacon_state, start_slot),
}
}
/// Create a new iterator over all blocks in the given `beacon_state` and prior states.
pub fn owned(store: Arc<U>, beacon_state: BeaconState<T>, start_slot: Slot) -> Self {
Self {
roots: BlockRootsIterator::owned(store, beacon_state, start_slot),
}
}
}
impl<'a, T: EthSpec, U: Store> Iterator for BlockIterator<'a, T, U> {
@@ -99,6 +113,15 @@ impl<'a, T: EthSpec, U: Store> BlockRootsIterator<'a, T, U> {
store,
}
}
/// Create a new iterator over all block roots in the given `beacon_state` and prior states.
pub fn owned(store: Arc<U>, beacon_state: BeaconState<T>, start_slot: Slot) -> Self {
Self {
slot: start_slot,
beacon_state: Cow::Owned(beacon_state),
store,
}
}
}
impl<'a, T: EthSpec, U: Store> Iterator for BlockRootsIterator<'a, T, U> {