pub(crate) async fn mpool_push_message<DB, KS, B, V>(
    data: Data<RpcState<DB, KS, B>>,
    Params(params): Params<(UnsignedMessageJson, Option<MessageSendSpec>)>,
) -> Result<SignedMessageJson, JsonRpcError>
where
    DB: BlockStore + Send + Sync + 'static,
    KS: KeyStore + Send + Sync + 'static,
    B: Beacon + Send + Sync + 'static,
    V: ProofVerifier + Send + Sync + 'static,
{
    let (UnsignedMessageJson(umsg), spec) = params;

    let from = *umsg.from();

    let keystore = data.keystore.as_ref().write().await;
    let heaviest_tipset = data
        .state_manager
        .chain_store()
        .heaviest_tipset()
        .await
        .ok_or_else(|| "Could not get heaviest tipset".to_string())?;
    let key_addr = data
        .state_manager
        .resolve_to_key_addr::<FullVerifier>(&from, &heaviest_tipset)
        .await?;

    if umsg.sequence() != 0 {
        return Err(
            "Expected nonce for MpoolPushMessage is 0, and will be calculated for you.".into(),
        );
    }
    let mut umsg =
        estimate_message_gas::<DB, KS, B, V>(&data, umsg, spec, Default::default()).await?;
    if umsg.gas_premium() > umsg.gas_fee_cap() {
        return Err("After estimation, gas premium is greater than gas fee cap".into());
    }

    if from.protocol() == Protocol::ID {
        umsg.from = key_addr;
    }
    let nonce = data.mpool.get_sequence(&from).await?;
    umsg.sequence = nonce;
    let key = wallet::find_key(&key_addr, &*keystore)?;
    let sig = wallet::sign(
        *key.key_info.key_type(),
        key.key_info.private_key(),
        umsg.to_signing_bytes().as_slice(),
    )?;

    let smsg = SignedMessage::new_from_parts(umsg, sig)?;

    data.mpool.as_ref().push(smsg.clone()).await?;

    Ok(SignedMessageJson(smsg))
}
/// Sign given UnsignedMessage and add it to mpool, return SignedMessage
Sign given UnsignedMessage and add it to mpool, return SignedMessage
Sign given UnsignedMessage and add it to mpool return SignedMessage
pub(crate) async fn mpool_push_message<DB, KS, B, V>(
    data: Data<RpcState<DB, KS, B>>,
    Params(params): Params<(UnsignedMessageJson, Option<MessageSendSpec>)>,
) -> Result<SignedMessageJson, JsonRpcError>
where
    DB: BlockStore + Send + Sync + 'static,
    KS: KeyStore + Send + Sync + 'static,
    B: Beacon + Send + Sync + 'static,
    V: ProofVerifier + Send + Sync + 'static,
{
    let (UnsignedMessageJson(umsg), spec) = params;
    let from = *umsg.from();
    let keystore = data.keystore.as_ref().write().await;
    let heaviest_tipset = data
        .state_manager
        .chain_store()
        .heaviest_tipset()
        .await
        .ok_or_else(|| "Could not get heaviest tipset".to_string())?;
    let key_addr = data
        .state_manager
        .resolve_to_key_addr::<FullVerifier>(&from, &heaviest_tipset)
        .await?;
    if umsg.sequence() != 0 {
        return Err(
            "Expected nonce for MpoolPushMessage is 0, and will be calculated for you.".into(),
        );
    }
    let mut umsg =
        estimate_message_gas::<DB, KS, B, V>(&data, umsg, spec, Default::default()).await?;
    if umsg.gas_premium() > umsg.gas_fee_cap() {
        return Err("After estimation, gas premium is greater than gas fee cap".into());
    }
    if from.protocol() == Protocol::ID {
        umsg.from = key_addr;
    }
    let nonce = data.mpool.get_sequence(&from).await?;
    umsg.sequence = nonce;
    let key = wallet::find_key(&key_addr, &*keystore)?;
    let sig = wallet::sign(
        *key.key_info.key_type(),
        key.key_info.private_key(),
        umsg.to_signing_bytes().as_slice(),
    )?;
    let smsg = SignedMessage::new_from_parts(umsg, sig)?;
    data.mpool.as_ref().push(smsg.clone()).await?;
    Ok(SignedMessageJson(smsg))
}
pub ( crate ) async fn mpool_push_message < DB , KS , B , V > ( data : Data < RpcState < DB , KS , B > > , Params ( params ) : Params < ( UnsignedMessageJson , Option < MessageSendSpec > ) > , ) -> Result < SignedMessageJson , JsonRpcError > where DB : BlockStore + Send + Sync + ' static , KS : KeyStore + Send + Sync + ' static , B : Beacon + Send + Sync + ' static , V : ProofVerifier + Send + Sync + ' static , { let ( UnsignedMessageJson ( umsg ) , spec ) = params ; let from = * umsg . from ( ) ; let keystore = data . keystore . as_ref ( ) . write ( ) . await ; let heaviest_tipset = data . state_manager . chain_store ( ) . heaviest_tipset ( ) . await . ok_or_else ( | | " " . to_string ( ) ) ? ; let key_addr = data . state_manager . resolve_to_key_addr :: < FullVerifier > ( & from , & heaviest_tipset ) . await ? ; if umsg . sequence ( ) != 0 { return Err ( " " . into ( ) , ) ; } let mut umsg = estimate_message_gas :: < DB , KS , B , V > ( & data , umsg , spec , Default :: default ( ) ) . await ? ; if umsg . gas_premium ( ) > umsg . gas_fee_cap ( ) { return Err ( " " . into ( ) ) ; } if from . protocol ( ) == Protocol :: ID { umsg . from = key_addr ; } let nonce = data . mpool . get_sequence ( & from ) . await ? ; umsg . sequence = nonce ; let key = wallet :: find_key ( & key_addr , & * keystore ) ? ; let sig = wallet :: sign ( * key . key_info . key_type ( ) , key . key_info . private_key ( ) , umsg . to_signing_bytes ( ) . as_slice ( ) , ) ? ; let smsg = SignedMessage :: new_from_parts ( umsg , sig ) ? ; data . mpool . as_ref ( ) . push ( smsg . clone ( ) ) . await ? ; Ok ( SignedMessageJson ( smsg ) ) }
Sign given UnsignedMessage and add it to mpool, return SignedMessage
Sign given UnsignedMessage and add it to mpool return SignedMessage
data
Params<(UnsignedMessageJson, Option<MessageSendSpec>)>