pub async fn push_with_sequence<V>(&self, addr: &Address, cb: T) -> Result<SignedMessage, Error>
    where
        T: Fn(Address, u64) -> Result<SignedMessage, Error>,
        V: ProofVerifier,
    {
        let cur_ts = self.cur_tipset.read().await.clone();
        let from_key = match addr.protocol() {
            Protocol::ID => {
                let api = self.api.read().await;

                api.state_account_key::<V>(&addr, &self.cur_tipset.read().await.clone())
                    .await?
            }
            _ => *addr,
        };

        let sequence = self.get_sequence(&addr).await?;
        let msg = cb(from_key, sequence)?;
        self.check_message(&msg).await?;
        if *self.cur_tipset.read().await != cur_ts {
            return Err(Error::TryAgain);
        }

        if self.get_sequence(&addr).await? != sequence {
            return Err(Error::TryAgain);
        }

        let publish = verify_msg_before_add(&msg, &cur_ts, true)?;
        self.check_balance(&msg, &cur_ts).await?;
        self.add_helper(msg.clone()).await?;
        self.add_local(msg.clone()).await?;

        if publish {
            self.network_sender
                .send(NetworkMessage::PubsubMessage {
                    topic: PUBSUB_MSG_TOPIC.clone(),
                    message: msg.marshal_cbor()?,
                })
                .await
                .map_err(|_| Error::Other("Network receiver dropped".to_string()))?;
        }

        Ok(msg)
    }
/// Adds a local message returned from the call back function with the current nonce
Adds a local message returned from the call back function with the current nonce
Adds a local message returned from the call back function with the current nonce
pub async fn push_with_sequence<V>(&self, addr: &Address, cb: T) -> Result<SignedMessage, Error>
    where
        T: Fn(Address, u64) -> Result<SignedMessage, Error>,
        V: ProofVerifier,
    {
        let cur_ts = self.cur_tipset.read().await.clone();
        let from_key = match addr.protocol() {
            Protocol::ID => {
                let api = self.api.read().await;
                api.state_account_key::<V>(&addr, &self.cur_tipset.read().await.clone())
                    .await?
            }
            _ => *addr,
        };
        let sequence = self.get_sequence(&addr).await?;
        let msg = cb(from_key, sequence)?;
        self.check_message(&msg).await?;
        if *self.cur_tipset.read().await != cur_ts {
            return Err(Error::TryAgain);
        }
        if self.get_sequence(&addr).await? != sequence {
            return Err(Error::TryAgain);
        }
        let publish = verify_msg_before_add(&msg, &cur_ts, true)?;
        self.check_balance(&msg, &cur_ts).await?;
        self.add_helper(msg.clone()).await?;
        self.add_local(msg.clone()).await?;
        if publish {
            self.network_sender
                .send(NetworkMessage::PubsubMessage {
                    topic: PUBSUB_MSG_TOPIC.clone(),
                    message: msg.marshal_cbor()?,
                })
                .await
                .map_err(|_| Error::Other("Network receiver dropped".to_string()))?;
        }
        Ok(msg)
    }
pub async fn push_with_sequence < V > ( & self , addr : & Address , cb : T ) -> Result < SignedMessage , Error > where T : Fn ( Address , u64 ) -> Result < SignedMessage , Error > , V : ProofVerifier , { let cur_ts = self . cur_tipset . read ( ) . await . clone ( ) ; let from_key = match addr . protocol ( ) { Protocol :: ID => { let api = self . api . read ( ) . await ; api . state_account_key :: < V > ( & addr , & self . cur_tipset . read ( ) . await . clone ( ) ) . await ? } _ => * addr , } ; let sequence = self . get_sequence ( & addr ) . await ? ; let msg = cb ( from_key , sequence ) ? ; self . check_message ( & msg ) . await ? ; if * self . cur_tipset . read ( ) . await != cur_ts { return Err ( Error :: TryAgain ) ; } if self . get_sequence ( & addr ) . await ? != sequence { return Err ( Error :: TryAgain ) ; } let publish = verify_msg_before_add ( & msg , & cur_ts , true ) ? ; self . check_balance ( & msg , & cur_ts ) . await ? ; self . add_helper ( msg . clone ( ) ) . await ? ; self . add_local ( msg . clone ( ) ) . await ? ; if publish { self . network_sender . send ( NetworkMessage :: PubsubMessage { topic : PUBSUB_MSG_TOPIC . clone ( ) , message : msg . marshal_cbor ( ) ? , } ) . await . map_err ( | _ | Error :: Other ( " " . to_string ( ) ) ) ? ; } Ok ( msg ) }
Adds a local message returned from the call back function with the current nonce
Adds a local message returned from the call back function with the current nonce
&self
addr
&Address
cb
T