pub fn chain_dump(&self) -> Result<Vec<BeaconSnapshot<T::EthSpec>>, Error> {
        let mut dump = vec![];

        let mut last_slot = BeaconSnapshot {
            beacon_block: self.head()?.beacon_block,
            beacon_block_root: self.head()?.beacon_block_root,
            beacon_state: self.head()?.beacon_state,
        };

        dump.push(last_slot.clone());

        loop {
            let beacon_block_root = last_slot.beacon_block.parent_root();

            if beacon_block_root == Hash256::zero() {
                break; // Genesis has been reached.
            }

            let beacon_block = self.store.get_block(&beacon_block_root)?.ok_or_else(|| {
                Error::DBInconsistent(format!("Missing block {}", beacon_block_root))
            })?;
            let beacon_state_root = beacon_block.state_root();
            let beacon_state = self
                .store
                .get_state(&beacon_state_root, Some(beacon_block.slot()))?
                .ok_or_else(|| {
                    Error::DBInconsistent(format!("Missing state {:?}", beacon_state_root))
                })?;

            let slot = BeaconSnapshot {
                beacon_block,
                beacon_block_root,
                beacon_state,
            };

            dump.push(slot.clone());
            last_slot = slot;
        }

        dump.reverse();

        Ok(dump)
    }
/// Dumps the entire canonical chain, from the head to genesis to a vector for analysis.
///
/// This could be a very expensive operation and should only be done in testing/analysis
/// activities.
Dumps the entire canonical chain, from the head to genesis to a vector for analysis.
This could be a very expensive operation and should only be done in testing/analysis
activities.
Dumps the entire canonical chain from the head to genesis to a vector for analysis . This could be a very expensive operation and should only be done in testing / analysis activities .
pub fn chain_dump(&self) -> Result<Vec<BeaconSnapshot<T::EthSpec>>, Error> {
        let mut dump = vec![];
        let mut last_slot = BeaconSnapshot {
            beacon_block: self.head()?.beacon_block,
            beacon_block_root: self.head()?.beacon_block_root,
            beacon_state: self.head()?.beacon_state,
        };
        dump.push(last_slot.clone());
        loop {
            let beacon_block_root = last_slot.beacon_block.parent_root();
            if beacon_block_root == Hash256::zero() {
                break; // Genesis has been reached.
            }
            let beacon_block = self.store.get_block(&beacon_block_root)?.ok_or_else(|| {
                Error::DBInconsistent(format!("Missing block {}", beacon_block_root))
            })?;
            let beacon_state_root = beacon_block.state_root();
            let beacon_state = self
                .store
                .get_state(&beacon_state_root, Some(beacon_block.slot()))?
                .ok_or_else(|| {
                    Error::DBInconsistent(format!("Missing state {:?}", beacon_state_root))
                })?;
            let slot = BeaconSnapshot {
                beacon_block,
                beacon_block_root,
                beacon_state,
            };
            dump.push(slot.clone());
            last_slot = slot;
        }
        dump.reverse();
        Ok(dump)
    }
pub fn chain_dump ( & self ) -> Result < Vec < BeaconSnapshot < T :: EthSpec > > , Error > { let mut dump = vec ! [ ] ; let mut last_slot = BeaconSnapshot { beacon_block : self . head ( ) ? . beacon_block , beacon_block_root : self . head ( ) ? . beacon_block_root , beacon_state : self . head ( ) ? . beacon_state , } ; dump . push ( last_slot . clone ( ) ) ; loop { let beacon_block_root = last_slot . beacon_block . parent_root ( ) ; if beacon_block_root == Hash256 :: zero ( ) { break ; // Genesis has been reached. } let beacon_block = self . store . get_block ( & beacon_block_root ) ? . ok_or_else ( | | { Error :: DBInconsistent ( format ! ( " " beacon_block_root ) ) } ) ? ; let beacon_state_root = beacon_block . state_root ( ) ; let beacon_state = self . store . get_state ( & beacon_state_root , Some ( beacon_block . slot ( ) ) ) ? . ok_or_else ( | | { Error :: DBInconsistent ( format ! ( " " beacon_state_root ) ) } ) ? ; let slot = BeaconSnapshot { beacon_block , beacon_block_root , beacon_state , } ; dump . push ( slot . clone ( ) ) ; last_slot = slot ; } dump . reverse ( ) ; Ok ( dump ) }
Dumps the entire canonical chain, from the head to genesis to a vector for analysis.
Dumps the entire canonical chain from the head to genesis to a vector for analysis .
&self