pub fn send_job(&mut self, job: &mut JobTemplate) -> Result<(), String> {
        trace!("Worker {} - Sending a job downstream: requested = {}", self.uuid(), self.requested_job);
        // Set the difficulty
        job.difficulty = self.status.difficulty;
        let requested = self.requested_job;
        self.needs_job = false;
        self.requested_job = false;
        let job_value = serde_json::to_value(job.clone()).unwrap();
        let result;
        if requested {
            result = self.send_response(
                "getjobtemplate".to_string(),
                job_value,
            );
        } else {
            result = self.protocol.send_request(
                &mut self.stream,
                "job".to_string(),
                Some(job_value.clone()),
                Some("Stratum".to_string()),    // XXX UGLY
            );
        }
        match result {
            Ok(r) => { return Ok(r); }
            Err(e) => {
                self.error = true;
                error!("{} - Failed to send job: {}", self.uuid(), e);
                return Err(format!("{}", e));
            }
        }
    }
// This handles both a get_job_template response, and a job request
/// Send a job to the worker
This handles both a get_job_template response, and a job request
Send a job to the worker
This handles both a get_job_template response and a job request Send a job to the worker
pub fn send_job(&mut self, job: &mut JobTemplate) -> Result<(), String> {
        trace!("Worker {} - Sending a job downstream: requested = {}", self.uuid(), self.requested_job);
        // Set the difficulty
        job.difficulty = self.status.difficulty;
        let requested = self.requested_job;
        self.needs_job = false;
        self.requested_job = false;
        let job_value = serde_json::to_value(job.clone()).unwrap();
        let result;
        if requested {
            result = self.send_response(
                "getjobtemplate".to_string(),
                job_value,
            );
        } else {
            result = self.protocol.send_request(
                &mut self.stream,
                "job".to_string(),
                Some(job_value.clone()),
                Some("Stratum".to_string()),    // XXX UGLY
            );
        }
        match result {
            Ok(r) => { return Ok(r); }
            Err(e) => {
                self.error = true;
                error!("{} - Failed to send job: {}", self.uuid(), e);
                return Err(format!("{}", e));
            }
        }
    }
pub fn send_job ( & mut self , job : & mut JobTemplate ) -> Result < ( ) , String > { trace ! ( " " self uuid ( ) self requested_job ) ; // Set the difficulty job . difficulty = self . status . difficulty ; let requested = self . requested_job ; self . needs_job = false ; self . requested_job = false ; let job_value = serde_json :: to_value ( job . clone ( ) ) . unwrap ( ) ; let result ; if requested { result = self . send_response ( " " . to_string ( ) , job_value , ) ; } else { result = self . protocol . send_request ( & mut self . stream , " " . to_string ( ) , Some ( job_value . clone ( ) ) , Some ( " " . to_string ( ) ) , // XXX UGLY ) ; } match result { Ok ( r ) => { return Ok ( r ) ; } Err ( e ) => { self . error = true ; error ! ( " " self uuid ( ) e ) ; return Err ( format ! ( " " e ) ) ; } } }
This handles both a get_job_template response, and a job request
Send a job to the worker
This handles both a get_job_template response and a job request Send a job to the worker
&mut self
job
&mut JobTemplate