pub async fn start_wallet(
    wallet: &mut WalletSqlite,
    base_node: &Peer,
    wallet_mode: &WalletMode,
) -> Result<(), ExitCodes> {
    // TODO gRPC interfaces for setting base node
    debug!(target: LOG_TARGET, "Setting base node peer");

    let net_address = base_node
        .addresses
        .first()
        .ok_or_else(|| ExitCodes::ConfigError("Configured base node has no address!".to_string()))?
        .to_string();

    wallet
        .set_base_node_peer(base_node.public_key.clone(), net_address)
        .await
        .map_err(|e| ExitCodes::WalletError(format!("Error setting wallet base node peer. {}", e)))?;

    // Restart transaction protocols if not running in script or command modes

    if !matches!(wallet_mode, WalletMode::Command(_)) && !matches!(wallet_mode, WalletMode::Script(_)) {
        if let Err(e) = wallet.transaction_service.restart_transaction_protocols().await {
            error!(target: LOG_TARGET, "Problem restarting transaction protocols: {}", e);
        }
        if let Err(e) = start_transaction_validation_and_broadcast_protocols(
            wallet.transaction_service.clone(),
            ValidationRetryStrategy::UntilSuccess,
        )
        .await
        {
            error!(
                target: LOG_TARGET,
                "Problem validating and restarting transaction protocols: {}", e
            );
        }

        // validate transaction outputs
        validate_txos(wallet).await?;
    }
    Ok(())
}
/// Starts the wallet by setting the base node peer, and restarting the transaction and broadcast protocols.
Starts the wallet by setting the base node peer, and restarting the transaction and broadcast protocols.
Starts the wallet by setting the base node peer and restarting the transaction and broadcast protocols .
pub async fn start_wallet(
    wallet: &mut WalletSqlite,
    base_node: &Peer,
    wallet_mode: &WalletMode,
) -> Result<(), ExitCodes> {
    // TODO gRPC interfaces for setting base node
    debug!(target: LOG_TARGET, "Setting base node peer");
    let net_address = base_node
        .addresses
        .first()
        .ok_or_else(|| ExitCodes::ConfigError("Configured base node has no address!".to_string()))?
        .to_string();
    wallet
        .set_base_node_peer(base_node.public_key.clone(), net_address)
        .await
        .map_err(|e| ExitCodes::WalletError(format!("Error setting wallet base node peer. {}", e)))?;
    // Restart transaction protocols if not running in script or command modes
    if !matches!(wallet_mode, WalletMode::Command(_)) && !matches!(wallet_mode, WalletMode::Script(_)) {
        if let Err(e) = wallet.transaction_service.restart_transaction_protocols().await {
            error!(target: LOG_TARGET, "Problem restarting transaction protocols: {}", e);
        }
        if let Err(e) = start_transaction_validation_and_broadcast_protocols(
            wallet.transaction_service.clone(),
            ValidationRetryStrategy::UntilSuccess,
        )
        .await
        {
            error!(
                target: LOG_TARGET,
                "Problem validating and restarting transaction protocols: {}", e
            );
        }
        // validate transaction outputs
        validate_txos(wallet).await?;
    }
    Ok(())
}
pub async fn start_wallet ( wallet : & mut WalletSqlite , base_node : & Peer , wallet_mode : & WalletMode , ) -> Result < ( ) , ExitCodes > { // TODO gRPC interfaces for setting base node debug ! ( target LOG_TARGET " " ) ; let net_address = base_node . addresses . first ( ) . ok_or_else ( | | ExitCodes :: ConfigError ( " " . to_string ( ) ) ) ? . to_string ( ) ; wallet . set_base_node_peer ( base_node . public_key . clone ( ) , net_address ) . await . map_err ( | e | ExitCodes :: WalletError ( format ! ( " " e ) ) ) ? ; // Restart transaction protocols if not running in script or command modes if ! matches ! ( wallet_mode WalletMode Command ( ) ) && ! matches ! ( wallet_mode WalletMode Script ( ) ) { if let Err ( e ) = wallet . transaction_service . restart_transaction_protocols ( ) . await { error ! ( target LOG_TARGET " " e ) ; } if let Err ( e ) = start_transaction_validation_and_broadcast_protocols ( wallet . transaction_service . clone ( ) , ValidationRetryStrategy :: UntilSuccess , ) . await { error ! ( target LOG_TARGET " " e ) ; } // validate transaction outputs validate_txos ( wallet ) . await ? ; } Ok ( ( ) ) }
Starts the wallet by setting the base node peer, and restarting the transaction and broadcast protocols.
Starts the wallet by setting the base node peer and restarting the transaction and broadcast protocols .
wallet
&mut WalletSqlite
base_node
&Peer
wallet_mode
&WalletMode
wallet
&mut WalletSqlite
base_node
&Peer
wallet_mode
&WalletMode