Impressive example of Traits usage

9 views
Skip to first unread message

Saifi

unread,
Aug 21, 2017, 4:26:31 PM8/21/17
to rus...@googlegroups.com
while studying the parity code
https://github.com/paritytech/parity/blob/master/stratum/src/traits.rs

here is the relevant extract

pub trait JobDispatcher: Send + Sync {
// json for initial client handshake
fn initial(&self) -> Option<String> { None }
// json for difficulty dispatch
fn difficulty(&self) -> Option<String> { None }
// json for job update given worker_id (payload manager should split job!)
fn job(&self) -> Option<String> { None }
// miner job result
fn submit(&self, payload: Vec<String>) -> Result<(), Error>;
}

Please see how the JobDispatcher is bound through 'Send' and 'Sync'.
Very impressive !

warm regards
Saifi.
Reply all
Reply to author
Forward
0 new messages