async fn start_coinbase_transaction_monitoring_protocol(
        &mut self,
        tx_id: TxId,
        join_handles: &mut FuturesUnordered<JoinHandle<Result<u64, TransactionServiceProtocolError>>>,
    ) -> Result<(), TransactionServiceError>
    {
        let completed_tx = self.db.get_completed_transaction(tx_id).await?;

        if completed_tx.status != TransactionStatus::Coinbase || completed_tx.coinbase_block_height.is_none() {
            return Err(TransactionServiceError::InvalidCompletedTransaction);
        }

        let block_height = if let Some(bh) = completed_tx.coinbase_block_height {
            bh
        } else {
            0
        };

        let timeout = match self.power_mode {
            PowerMode::Normal => self.config.broadcast_monitoring_timeout,
            PowerMode::Low => self.config.low_power_polling_timeout,
        };
        match self.base_node_public_key.clone() {
            None => return Err(TransactionServiceError::NoBaseNodeKeysProvided),
            Some(pk) => {
                let protocol_id = OsRng.next_u64();

                let (base_node_response_sender, base_node_response_receiver) = mpsc::channel(100);
                self.base_node_response_senders
                    .insert(protocol_id, base_node_response_sender);
                let protocol = TransactionCoinbaseMonitoringProtocol::new(
                    protocol_id,
                    completed_tx.tx_id,
                    block_height,
                    self.resources.clone(),
                    timeout,
                    pk,
                    base_node_response_receiver,
                    self.timeout_update_publisher.subscribe(),
                );
                let join_handle = tokio::spawn(protocol.execute());
                join_handles.push(join_handle);
            },
        }
        Ok(())
    }
/// Send a request to the Base Node to see if the specified coinbase transaction has been mined yet. This function
/// will send the request and store a timeout future to check in on the status of the transaction in the future.
Send a request to the Base Node to see if the specified coinbase transaction has been mined yet. This function
will send the request and store a timeout future to check in on the status of the transaction in the future.
Send a request to the Base Node to see if the specified coinbase transaction has been mined yet . This function will send the request and store a timeout future to check in on the status of the transaction in the future .
async fn start_coinbase_transaction_monitoring_protocol(
        &mut self,
        tx_id: TxId,
        join_handles: &mut FuturesUnordered<JoinHandle<Result<u64, TransactionServiceProtocolError>>>,
    ) -> Result<(), TransactionServiceError>
    {
        let completed_tx = self.db.get_completed_transaction(tx_id).await?;
        if completed_tx.status != TransactionStatus::Coinbase || completed_tx.coinbase_block_height.is_none() {
            return Err(TransactionServiceError::InvalidCompletedTransaction);
        }
        let block_height = if let Some(bh) = completed_tx.coinbase_block_height {
            bh
        } else {
            0
        };
        let timeout = match self.power_mode {
            PowerMode::Normal => self.config.broadcast_monitoring_timeout,
            PowerMode::Low => self.config.low_power_polling_timeout,
        };
        match self.base_node_public_key.clone() {
            None => return Err(TransactionServiceError::NoBaseNodeKeysProvided),
            Some(pk) => {
                let protocol_id = OsRng.next_u64();
                let (base_node_response_sender, base_node_response_receiver) = mpsc::channel(100);
                self.base_node_response_senders
                    .insert(protocol_id, base_node_response_sender);
                let protocol = TransactionCoinbaseMonitoringProtocol::new(
                    protocol_id,
                    completed_tx.tx_id,
                    block_height,
                    self.resources.clone(),
                    timeout,
                    pk,
                    base_node_response_receiver,
                    self.timeout_update_publisher.subscribe(),
                );
                let join_handle = tokio::spawn(protocol.execute());
                join_handles.push(join_handle);
            },
        }
        Ok(())
    }
async fn start_coinbase_transaction_monitoring_protocol ( & mut self , tx_id : TxId , join_handles : & mut FuturesUnordered < JoinHandle < Result < u64 , TransactionServiceProtocolError > > > , ) -> Result < ( ) , TransactionServiceError > { let completed_tx = self . db . get_completed_transaction ( tx_id ) . await ? ; if completed_tx . status != TransactionStatus :: Coinbase || completed_tx . coinbase_block_height . is_none ( ) { return Err ( TransactionServiceError :: InvalidCompletedTransaction ) ; } let block_height = if let Some ( bh ) = completed_tx . coinbase_block_height { bh } else { 0 } ; let timeout = match self . power_mode { PowerMode :: Normal => self . config . broadcast_monitoring_timeout , PowerMode :: Low => self . config . low_power_polling_timeout , } ; match self . base_node_public_key . clone ( ) { None => return Err ( TransactionServiceError :: NoBaseNodeKeysProvided ) , Some ( pk ) => { let protocol_id = OsRng . next_u64 ( ) ; let ( base_node_response_sender , base_node_response_receiver ) = mpsc :: channel ( 100 ) ; self . base_node_response_senders . insert ( protocol_id , base_node_response_sender ) ; let protocol = TransactionCoinbaseMonitoringProtocol :: new ( protocol_id , completed_tx . tx_id , block_height , self . resources . clone ( ) , timeout , pk , base_node_response_receiver , self . timeout_update_publisher . subscribe ( ) , ) ; let join_handle = tokio :: spawn ( protocol . execute ( ) ) ; join_handles . push ( join_handle ) ; } , } Ok ( ( ) ) }
Send a request to the Base Node to see if the specified coinbase transaction has been mined yet.
Send a request to the Base Node to see if the specified coinbase transaction has been mined yet .
&mut self
tx_id
TxId
join_handles
&mut FuturesUnordered<JoinHandle<Result<u64, TransactionServiceProtocolError>>>
&mut self
tx_id
TxId
join_handles
&mut FuturesUnordered<JoinHandle<Result<u64, TransactionServiceProtocolError>>>