pub async fn export<W>(
        &self,
        tipset: &Tipset,
        recent_roots: ChainEpoch,
        skip_old_msgs: bool,
        mut writer: W,
    ) -> Result<(), Error>
    where
        W: AsyncWrite + Send + Unpin + 'static,
    {
        // Channel cap is equal to buffered write size
        const CHANNEL_CAP: usize = 1000;
        let (tx, mut rx) = bounded(CHANNEL_CAP);
        let header = CarHeader::from(tipset.key().cids().to_vec());
        let write_task =
            task::spawn(async move { header.write_stream_async(&mut writer, &mut rx).await });

        let global_pre_time = SystemTime::now();
        info!("chain export started");
        Self::walk_snapshot(tipset, recent_roots, skip_old_msgs, |cid| {
            let block = self
                .blockstore()
                .get_bytes(&cid)?
                .ok_or_else(|| format!("Cid {} not found in blockstore", cid))?;

            // * If cb can return a generic type, deserializing would remove need to clone.
            // Ignore error intentionally, if receiver dropped, error will be handled below
            let _ = task::block_on(tx.send((cid, block.clone())));
            Ok(block)
        })
        .await?;

        // Drop sender, to close the channel to write task, which will end when finished writing
        drop(tx);

        // Await on values being written.
        write_task
            .await
            .map_err(|e| Error::Other(format!("Failed to write blocks in export: {}", e)))?;

        let time = SystemTime::now()
            .duration_since(global_pre_time)
            .expect("time cannot go backwards");
        info!("export finished, took {} seconds", time.as_secs());

        Ok(())
    }
/// Exports a range of tipsets, as well as the state roots based on the `recent_roots`.
Exports a range of tipsets, as well as the state roots based on the `recent_roots`.
Exports a range of tipsets as well as the state roots based on the ` recent_roots ` .
pub async fn export<W>(
        &self,
        tipset: &Tipset,
        recent_roots: ChainEpoch,
        skip_old_msgs: bool,
        mut writer: W,
    ) -> Result<(), Error>
    where
        W: AsyncWrite + Send + Unpin + 'static,
    {
        // Channel cap is equal to buffered write size
        const CHANNEL_CAP: usize = 1000;
        let (tx, mut rx) = bounded(CHANNEL_CAP);
        let header = CarHeader::from(tipset.key().cids().to_vec());
        let write_task =
            task::spawn(async move { header.write_stream_async(&mut writer, &mut rx).await });
        let global_pre_time = SystemTime::now();
        info!("chain export started");
        Self::walk_snapshot(tipset, recent_roots, skip_old_msgs, |cid| {
            let block = self
                .blockstore()
                .get_bytes(&cid)?
                .ok_or_else(|| format!("Cid {} not found in blockstore", cid))?;
            // * If cb can return a generic type, deserializing would remove need to clone.
            // Ignore error intentionally, if receiver dropped, error will be handled below
            let _ = task::block_on(tx.send((cid, block.clone())));
            Ok(block)
        })
        .await?;
        // Drop sender, to close the channel to write task, which will end when finished writing
        drop(tx);
        // Await on values being written.
        write_task
            .await
            .map_err(|e| Error::Other(format!("Failed to write blocks in export: {}", e)))?;
        let time = SystemTime::now()
            .duration_since(global_pre_time)
            .expect("time cannot go backwards");
        info!("export finished, took {} seconds", time.as_secs());
        Ok(())
    }
pub async fn export < W > ( & self , tipset : & Tipset , recent_roots : ChainEpoch , skip_old_msgs : bool , mut writer : W , ) -> Result < ( ) , Error > where W : AsyncWrite + Send + Unpin + ' static , { // Channel cap is equal to buffered write size const CHANNEL_CAP : usize = 1000 ; let ( tx , mut rx ) = bounded ( CHANNEL_CAP ) ; let header = CarHeader :: from ( tipset . key ( ) . cids ( ) . to_vec ( ) ) ; let write_task = task :: spawn ( async move { header . write_stream_async ( & mut writer , & mut rx ) . await } ) ; let global_pre_time = SystemTime :: now ( ) ; info ! ( " " ) ; Self :: walk_snapshot ( tipset , recent_roots , skip_old_msgs , | cid | { let block = self . blockstore ( ) . get_bytes ( & cid ) ? . ok_or_else ( | | format ! ( " " cid ) ) ? ; // * If cb can return a generic type, deserializing would remove need to clone. // Ignore error intentionally, if receiver dropped, error will be handled below let _ = task :: block_on ( tx . send ( ( cid , block . clone ( ) ) ) ) ; Ok ( block ) } ) . await ? ; // Drop sender, to close the channel to write task, which will end when finished writing drop ( tx ) ; // Await on values being written. write_task . await . map_err ( | e | Error :: Other ( format ! ( " " e ) ) ) ? ; let time = SystemTime :: now ( ) . duration_since ( global_pre_time ) . expect ( " " ) ; info ! ( " " time as_secs ( ) ) ; Ok ( ( ) ) }
Exports a range of tipsets, as well as the state roots based on the `recent_roots`.
Exports a range of tipsets as well as the state roots based on the ` recent_roots ` .
&self
tipset
&Tipset
recent_roots
ChainEpoch
skip_old_msgs
bool
writer
W