pub fn connect(&mut self) -> Result<(), String> {
        // Only connect if we are not already connected
        if !self.error && self.stream.is_some() {
            return Ok(());
        }
        let grin_stratum_url = self.config.grin_node.address.clone() + ":"
            + &self.config.grin_node.stratum_port.to_string();
        warn!(
            "{} - Connecting to upstream stratum server at {}",
            self.id,
            grin_stratum_url.to_string()
        );
        match TcpStream::connect(grin_stratum_url.to_string()) {
            Ok(conn) => {
                let _ = conn.set_nonblocking(true)
                    .expect("set_nonblocking call failed");
                self.stream = Some(BufStream::new(conn));
                self.error = false;
            }
            Err(e) => {
                self.error = true;
                return Err(e.to_string());
            }
        };
        // Send login
        match self.log_in() {
            Ok(_) => {}
            Err(e) => {
                self.error = true;
                return Err(e.to_string());
            }
        };
        // Send job request
        match self.request_job() {
            Ok(_) => {}
            Err(e) => {
                self.error = true;
                return Err(e.to_string());
            }
        };
        return Ok(());
    }
/// Connect to an upstream Grin Stratum Server
/// Request Login and Job Request
Connect to an upstream Grin Stratum Server
Request Login and Job Request
Connect to an upstream Grin Stratum Server Request Login and Job Request
pub fn connect(&mut self) -> Result<(), String> {
        // Only connect if we are not already connected
        if !self.error && self.stream.is_some() {
            return Ok(());
        }
        let grin_stratum_url = self.config.grin_node.address.clone() + ":"
            + &self.config.grin_node.stratum_port.to_string();
        warn!(
            "{} - Connecting to upstream stratum server at {}",
            self.id,
            grin_stratum_url.to_string()
        );
        match TcpStream::connect(grin_stratum_url.to_string()) {
            Ok(conn) => {
                let _ = conn.set_nonblocking(true)
                    .expect("set_nonblocking call failed");
                self.stream = Some(BufStream::new(conn));
                self.error = false;
            }
            Err(e) => {
                self.error = true;
                return Err(e.to_string());
            }
        };
        // Send login
        match self.log_in() {
            Ok(_) => {}
            Err(e) => {
                self.error = true;
                return Err(e.to_string());
            }
        };
        // Send job request
        match self.request_job() {
            Ok(_) => {}
            Err(e) => {
                self.error = true;
                return Err(e.to_string());
            }
        };
        return Ok(());
    }
pub fn connect ( & mut self ) -> Result < ( ) , String > { // Only connect if we are not already connected if ! self . error && self . stream . is_some ( ) { return Ok ( ( ) ) ; } let grin_stratum_url = self . config . grin_node . address . clone ( ) + " " + & self . config . grin_node . stratum_port . to_string ( ) ; warn ! ( " " self id grin_stratum_url to_string ( ) ) ; match TcpStream :: connect ( grin_stratum_url . to_string ( ) ) { Ok ( conn ) => { let _ = conn . set_nonblocking ( true ) . expect ( " " ) ; self . stream = Some ( BufStream :: new ( conn ) ) ; self . error = false ; } Err ( e ) => { self . error = true ; return Err ( e . to_string ( ) ) ; } } ; // Send login match self . log_in ( ) { Ok ( _ ) => { } Err ( e ) => { self . error = true ; return Err ( e . to_string ( ) ) ; } } ; // Send job request match self . request_job ( ) { Ok ( _ ) => { } Err ( e ) => { self . error = true ; return Err ( e . to_string ( ) ) ; } } ; return Ok ( ( ) ) ; }
Connect to an upstream Grin Stratum Server
Request Login and Job Request
Connect to an upstream Grin Stratum Server Request Login and Job Request
&mut self