/// Insert an unconfirmed transaction into the Mempool. The transaction *MUST* have passed through the validation
/// pipeline already and will thus always be internally consistent by this stage
Insert an unconfirmed transaction into the Mempool. The transaction *MUST* have passed through the validation
pipeline already and will thus always be internally consistent by this stage
Insert an unconfirmed transaction into the Mempool . The transaction * MUST * have passed through the validation pipeline already and will thus always be internally consistent by this stage
pub fn insert(&mut self, tx: Arc<Transaction>) -> Result<TxStorageResponse, MempoolError> {
        debug!(
            target: LOG_TARGET,
            "Inserting tx into mempool: {}",
            tx.body
                .kernels()
                .first()
                .map(|k| k.excess_sig.get_signature().to_hex())
                .unwrap_or_else(|| "None".into())
        );
        match self.validator.validate(&tx) {
            Ok(()) => {
                self.unconfirmed_pool.insert(tx)?;
                Ok(TxStorageResponse::UnconfirmedPool)
            },
            Err(ValidationError::UnknownInputs) => {
                self.orphan_pool.insert(tx)?;
                Ok(TxStorageResponse::OrphanPool)
            },
            Err(ValidationError::ContainsSTxO) => {
                self.reorg_pool.insert(tx)?;
                Ok(TxStorageResponse::ReorgPool)
            },
            Err(ValidationError::MaturityError) => {
                self.pending_pool.insert(tx)?;
                Ok(TxStorageResponse::PendingPool)
            },
            _ => Ok(TxStorageResponse::NotStored),
        }
    }
pub fn insert ( & mut self , tx : Arc < Transaction > ) -> Result < TxStorageResponse , MempoolError > { debug ! ( target LOG_TARGET " " tx body kernels ( ) first ( ) map ( k k excess_sig get_signature ( ) to_hex ( ) ) unwrap_or_else ( " " into ( ) ) ) ; match self . validator . validate ( & tx ) { Ok ( ( ) ) => { self . unconfirmed_pool . insert ( tx ) ? ; Ok ( TxStorageResponse :: UnconfirmedPool ) } , Err ( ValidationError :: UnknownInputs ) => { self . orphan_pool . insert ( tx ) ? ; Ok ( TxStorageResponse :: OrphanPool ) } , Err ( ValidationError :: ContainsSTxO ) => { self . reorg_pool . insert ( tx ) ? ; Ok ( TxStorageResponse :: ReorgPool ) } , Err ( ValidationError :: MaturityError ) => { self . pending_pool . insert ( tx ) ? ; Ok ( TxStorageResponse :: PendingPool ) } , _ => Ok ( TxStorageResponse :: NotStored ) , } }
Insert an unconfirmed transaction into the Mempool.
Insert an unconfirmed transaction into the Mempool .
&mut self
tx
Arc<Transaction>