async fn sync_fork(&self, head: &Tipset, to: &Tipset) -> Result<Vec<Arc<Tipset>>, Error> {
        // TODO move to shared parameter (from actors crate most likely)
        const FORK_LENGTH_THRESHOLD: u64 = 500;

        // TODO make this request more flexible with the window size, shouldn't require a node
        // to have to request all fork length headers at once.
        let tips = self
            .network
            .chain_exchange_headers(None, head.parents(), FORK_LENGTH_THRESHOLD)
            .await?;

        let mut ts = self.chain_store().tipset_from_keys(to.parents()).await?;

        for (i, tip) in tips.iter().enumerate() {
            while ts.epoch() > tip.epoch() {
                if ts.epoch() == 0 {
                    return Err(Error::Other(
                        "Synced chain forked at genesis, refusing to sync".to_string(),
                    ));
                }
                ts = self.chain_store().tipset_from_keys(ts.parents()).await?;
            }
            if ts == *tip {
                let mut tips = tips;
                tips.drain((i + 1)..);
                return Ok(tips);
            }
        }

        Err(Error::Other(
            "Fork longer than threshold finality of 500".to_string(),
        ))
    }
/// fork detected, collect tipsets to be included in return_set sync_headers_reverse
fork detected, collect tipsets to be included in return_set sync_headers_reverse
fork detected collect tipsets to be included in return_set sync_headers_reverse
async fn sync_fork(&self, head: &Tipset, to: &Tipset) -> Result<Vec<Arc<Tipset>>, Error> {
        // TODO move to shared parameter (from actors crate most likely)
        const FORK_LENGTH_THRESHOLD: u64 = 500;
        // TODO make this request more flexible with the window size, shouldn't require a node
        // to have to request all fork length headers at once.
        let tips = self
            .network
            .chain_exchange_headers(None, head.parents(), FORK_LENGTH_THRESHOLD)
            .await?;
        let mut ts = self.chain_store().tipset_from_keys(to.parents()).await?;
        for (i, tip) in tips.iter().enumerate() {
            while ts.epoch() > tip.epoch() {
                if ts.epoch() == 0 {
                    return Err(Error::Other(
                        "Synced chain forked at genesis, refusing to sync".to_string(),
                    ));
                }
                ts = self.chain_store().tipset_from_keys(ts.parents()).await?;
            }
            if ts == *tip {
                let mut tips = tips;
                tips.drain((i + 1)..);
                return Ok(tips);
            }
        }
        Err(Error::Other(
            "Fork longer than threshold finality of 500".to_string(),
        ))
    }
async fn sync_fork ( & self , head : & Tipset , to : & Tipset ) -> Result < Vec < Arc < Tipset > > , Error > { // TODO move to shared parameter (from actors crate most likely) const FORK_LENGTH_THRESHOLD : u64 = 500 ; // TODO make this request more flexible with the window size, shouldn't require a node // to have to request all fork length headers at once. let tips = self . network . chain_exchange_headers ( None , head . parents ( ) , FORK_LENGTH_THRESHOLD ) . await ? ; let mut ts = self . chain_store ( ) . tipset_from_keys ( to . parents ( ) ) . await ? ; for ( i , tip ) in tips . iter ( ) . enumerate ( ) { while ts . epoch ( ) > tip . epoch ( ) { if ts . epoch ( ) == 0 { return Err ( Error :: Other ( " " . to_string ( ) , ) ) ; } ts = self . chain_store ( ) . tipset_from_keys ( ts . parents ( ) ) . await ? ; } if ts == * tip { let mut tips = tips ; tips . drain ( ( i + 1 ) .. ) ; return Ok ( tips ) ; } } Err ( Error :: Other ( " " . to_string ( ) , ) ) }
fork detected, collect tipsets to be included in return_set sync_headers_reverse
fork detected collect tipsets to be included in return_set sync_headers_reverse
&self
head
&Tipset
to
&Tipset