Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restructure node and change protobuf generation location #7

Merged
merged 3 commits into from
Aug 31, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@ Cargo.lock
/target
**/*.rs.bk
*.swp
/src/protos
/docs/build
17 changes: 11 additions & 6 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,29 @@ extern crate protoc_rust;

use protoc_rust::Customize;

use std::env;
use std::fs;
use std::fs::File;
use std::io::prelude::*;
use std::io::Write;
use std::path::Path;

fn main() {
fs::create_dir_all("src/protos").unwrap();
let out_dir = env::var("OUT_DIR").unwrap();
let dest_path = Path::new(&out_dir).join("protos");
let proto_path = Path::new("./protos");
fs::create_dir_all(&dest_path).unwrap();

// Run protoc
protoc_rust::run(protoc_rust::Args {
out_dir: "src/protos",
input: &["protos/pbft_message.proto"],
includes: &["protos"],
out_dir: &dest_path.to_str().unwrap(),
input: &[proto_path.join("pbft_message.proto").to_str().unwrap()],
includes: &[proto_path.to_str().unwrap()],
customize: Customize {
..Default::default()
},
}).expect("Protoc Error");

// Create mod.rs accordingly
let mut mod_file = File::create("src/protos/mod.rs").unwrap();
let mut mod_file = File::create(dest_path.join("mod.rs")).unwrap();
mod_file.write_all(b"pub mod pbft_message;\n").unwrap();
}
13 changes: 0 additions & 13 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,6 @@ use protos::pbft_message::PbftBlock;

use message_type::PbftMessageType;

/// Enum for showing the difference between future messages, present messages, and past messages.
#[derive(Debug, PartialEq)]
pub enum PbftNotReadyType {
/// A future message. The node is not ready to process it yet.
PushToBacklog,

/// A past message. It's possible the node may still need it though, so it is added to the log.
AddToLog,

/// A present message. The node is ready to process this message immediately.
Proceed,
}

/// Errors that might occur in a PbftNode
#[derive(Debug)]
pub enum PbftError {
Expand Down
Loading