async fn update_heaviest(&self, ts: Arc<Tipset>) -> Result<(), Error> {
        // Calculate heaviest weight before matching to avoid deadlock with mutex
        let heaviest_weight = self
            .heaviest
            .read()
            .await
            .as_ref()
            .map(|ts| weight(self.db.as_ref(), ts.as_ref()));
        match heaviest_weight {
            Some(heaviest) => {
                let new_weight = weight(self.blockstore(), ts.as_ref())?;
                let curr_weight = heaviest?;
                if new_weight > curr_weight {
                    // TODO potentially need to deal with re-orgs here
                    info!("New heaviest tipset");
                    self.set_heaviest_tipset(ts).await?;
                }
            }
            None => {
                info!("set heaviest tipset");
                self.set_heaviest_tipset(ts).await?;
            }
        }
        Ok(())
    }
/// Determines if provided tipset is heavier than existing known heaviest tipset
Determines if provided tipset is heavier than existing known heaviest tipset
Determines if provided tipset is heavier than existing known heaviest tipset
async fn update_heaviest(&self, ts: Arc<Tipset>) -> Result<(), Error> {
        // Calculate heaviest weight before matching to avoid deadlock with mutex
        let heaviest_weight = self
            .heaviest
            .read()
            .await
            .as_ref()
            .map(|ts| weight(self.db.as_ref(), ts.as_ref()));
        match heaviest_weight {
            Some(heaviest) => {
                let new_weight = weight(self.blockstore(), ts.as_ref())?;
                let curr_weight = heaviest?;
                if new_weight > curr_weight {
                    // TODO potentially need to deal with re-orgs here
                    info!("New heaviest tipset");
                    self.set_heaviest_tipset(ts).await?;
                }
            }
            None => {
                info!("set heaviest tipset");
                self.set_heaviest_tipset(ts).await?;
            }
        }
        Ok(())
    }
async fn update_heaviest ( & self , ts : Arc < Tipset > ) -> Result < ( ) , Error > { // Calculate heaviest weight before matching to avoid deadlock with mutex let heaviest_weight = self . heaviest . read ( ) . await . as_ref ( ) . map ( | ts | weight ( self . db . as_ref ( ) , ts . as_ref ( ) ) ) ; match heaviest_weight { Some ( heaviest ) => { let new_weight = weight ( self . blockstore ( ) , ts . as_ref ( ) ) ? ; let curr_weight = heaviest ? ; if new_weight > curr_weight { // TODO potentially need to deal with re-orgs here info ! ( " " ) ; self . set_heaviest_tipset ( ts ) . await ? ; } } None => { info ! ( " " ) ; self . set_heaviest_tipset ( ts ) . await ? ; } } Ok ( ( ) ) }
Determines if provided tipset is heavier than existing known heaviest tipset
Determines if provided tipset is heavier than existing known heaviest tipset
&self
ts
Arc<Tipset>