Skip to content

Commit

Permalink
Merge pull request hyperledger-archives#1721 from aludvik/rust-csdk-e…
Browse files Browse the repository at this point in the history
…ngine-trait

Remove Sync + Send trait bound from Rust Consensus Engine trait
  • Loading branch information
Adam M Ludvik authored Jun 25, 2018
2 parents 9ee5ab8 + c69097d commit d6ae9fb
Show file tree
Hide file tree
Showing 7 changed files with 851 additions and 776 deletions.
19 changes: 6 additions & 13 deletions sdk/examples/devmode_rust/src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,19 +186,17 @@ impl DevmodeService {
}
}

pub struct DevmodeEngine {
exit: Exit,
}
pub struct DevmodeEngine {}

impl DevmodeEngine {
pub fn new() -> Self {
DevmodeEngine { exit: Exit::new() }
DevmodeEngine {}
}
}

impl Engine for DevmodeEngine {
fn start(
&self,
&mut self,
updates: Receiver<Update>,
service: Box<Service>,
mut chain_head: Block,
Expand All @@ -219,15 +217,14 @@ impl Engine for DevmodeEngine {
loop {
let incoming_message = updates.recv_timeout(time::Duration::from_millis(10));

if self.exit.get() {
break;
}

match incoming_message {
Ok(update) => {
debug!("Received message: {:?}", update);

match update {
Update::Shutdown => {
break;
}
Update::BlockNew(block) => {
info!("Checking consensus data: {:?}", block);

Expand Down Expand Up @@ -333,10 +330,6 @@ impl Engine for DevmodeEngine {
}
}

fn stop(&self) {
self.exit.set();
}

fn version(&self) -> String {
"0.1".into()
}
Expand Down
7 changes: 3 additions & 4 deletions sdk/examples/devmode_rust/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ use log4rs::config::{Appender, Config, Root};
use log4rs::encode::pattern::PatternEncoder;

use engine::DevmodeEngine;
use sawtooth_sdk::consensus::{driver::Driver, zmq_driver::ZmqDriver};
use sawtooth_sdk::consensus::zmq_driver::ZmqDriver;

fn main() {
let matches = clap_app!(intkey =>
Expand Down Expand Up @@ -76,9 +76,8 @@ fn main() {
process::exit(1);
});

let driver = ZmqDriver::new(Box::new(DevmodeEngine::new()));

driver.start(&endpoint).unwrap_or_else(|err| {
let (driver, _stop) = ZmqDriver::new();
driver.start(endpoint, DevmodeEngine::new()).unwrap_or_else(|err| {
error!("{}", err);
process::exit(1);
});
Expand Down
61 changes: 0 additions & 61 deletions sdk/rust/src/consensus/driver.rs

This file was deleted.

Loading

0 comments on commit d6ae9fb

Please sign in to comment.