-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
334 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,16 @@ | ||
fn main() -> Result<(), Box<dyn std::error::Error>> { | ||
// tonic_build::compile_protos("src/proto/blocks.proto")?; | ||
let mut builder = tonic_build::configure(); | ||
|
||
// Custom type attributes required for malachite | ||
builder = builder.type_attribute("snapchain.ShardHash", "#[derive(Eq, PartialOrd, Ord)]"); | ||
|
||
builder.compile(&["src/proto/blocks.proto"], &["src/proto"])?; | ||
// TODO: auto-discover proto files | ||
builder.compile(&[ | ||
"src/proto/blocks.proto", | ||
"src/proto/rpc.proto", | ||
"src/proto/message.proto", | ||
"src/proto/username_proof.proto", | ||
], &["src/proto"])?; | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
pub mod gossip; | ||
pub mod server; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
use std::error::Error; | ||
use std::net::SocketAddr; | ||
use tonic::{transport::Server, Request, Response, Status}; | ||
use tonic::Code::Unimplemented; | ||
use tracing::{info}; | ||
use hex::ToHex; | ||
|
||
|
||
pub mod rpc { | ||
tonic::include_proto!("rpc"); | ||
} | ||
|
||
pub mod message { | ||
tonic::include_proto!("message"); | ||
} | ||
|
||
pub mod username_proof { | ||
tonic::include_proto!("username_proof"); | ||
} | ||
|
||
use rpc::snapchain_service_server::{SnapchainService, SnapchainServiceServer}; | ||
use message::{Message}; | ||
|
||
#[derive(Default)] | ||
pub struct MySnapchainService; | ||
|
||
#[tonic::async_trait] | ||
impl SnapchainService for MySnapchainService { | ||
async fn submit_message(&self, request: Request<Message>) -> Result<Response<Message>, Status> { | ||
let hash = request.get_ref().hash.encode_hex::<String>(); | ||
info!(hash, "Received a message"); | ||
Err(Status::new(Unimplemented, "not implemented")) | ||
} | ||
} |
Oops, something went wrong.