one commit contains all impl
This commit is contained in:
13
libvanity/Cargo.toml
Normal file
13
libvanity/Cargo.toml
Normal file
@ -0,0 +1,13 @@
|
||||
[package]
|
||||
name = "libvanity"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
tonic = "0.8"
|
||||
prost = "0.11"
|
||||
|
||||
[build-dependencies]
|
||||
tonic-build = "0.8"
|
11
libvanity/build.rs
Normal file
11
libvanity/build.rs
Normal file
@ -0,0 +1,11 @@
|
||||
fn main() -> std::io::Result<()> {
|
||||
let descriptor_path =
|
||||
std::path::PathBuf::from(std::env::var("OUT_DIR").unwrap()).join("descriptor.bin");
|
||||
tonic_build::configure()
|
||||
.build_client(true)
|
||||
.build_server(true)
|
||||
.file_descriptor_set_path(descriptor_path)
|
||||
.compile(&["vanity.proto", "worker.proto"], &["protos"])?;
|
||||
|
||||
Ok(())
|
||||
}
|
15
libvanity/protos/vanity.proto
Normal file
15
libvanity/protos/vanity.proto
Normal file
@ -0,0 +1,15 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package vanity;
|
||||
|
||||
message VanityRequest {
|
||||
string pattern = 1;
|
||||
}
|
||||
|
||||
message VanityResponse {
|
||||
string result = 1;
|
||||
}
|
||||
|
||||
service VanityService {
|
||||
rpc RequestVanity(VanityRequest) returns (VanityResponse);
|
||||
}
|
26
libvanity/protos/worker.proto
Normal file
26
libvanity/protos/worker.proto
Normal file
@ -0,0 +1,26 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package worker;
|
||||
|
||||
import "vanity.proto";
|
||||
|
||||
message NewRequest {
|
||||
uint64 id = 1;
|
||||
string pattern = 2;
|
||||
}
|
||||
|
||||
message Request {
|
||||
oneof NewOrDone {
|
||||
NewRequest new = 1;
|
||||
uint64 done = 2;
|
||||
}
|
||||
}
|
||||
|
||||
message Result {
|
||||
uint64 id = 1;
|
||||
string result = 2;
|
||||
}
|
||||
|
||||
service Worker {
|
||||
rpc Poll(stream Result) returns (stream Request);
|
||||
}
|
9
libvanity/src/lib.rs
Normal file
9
libvanity/src/lib.rs
Normal file
@ -0,0 +1,9 @@
|
||||
pub mod vanity {
|
||||
tonic::include_proto!("vanity");
|
||||
}
|
||||
|
||||
pub mod worker {
|
||||
tonic::include_proto!("worker");
|
||||
}
|
||||
|
||||
pub const FILE_DESCRIPTOR_SET: &[u8] = tonic::include_file_descriptor_set!("descriptor");
|
Reference in New Issue
Block a user