one commit contains all impl

This commit is contained in:
2022-10-21 15:09:22 +08:00
commit e871ec2b29
17 changed files with 2117 additions and 0 deletions

16
vanity/Cargo.toml Normal file
View File

@ -0,0 +1,16 @@
[package]
name = "vanity"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
clap = { version = "4", features = ["derive", "env", "cargo"] }
tonic = "0.8"
tokio = {version = "1", features = ["full"]}
tokio-stream = { version = "0.1.11", features = ["net"] }
libvanity = {path = "../libvanity"}

30
vanity/src/main.rs Normal file
View File

@ -0,0 +1,30 @@
use clap::Parser;
use libvanity::vanity::VanityRequest;
#[derive(clap::Parser, Debug)]
#[clap(
about = "ask some worker to generate a private key where public key matches some regular expression"
)]
struct Args {
#[clap(short = 'c', long = "connect", help = "server address to connect to")]
endpoint: String,
#[clap(help = "pattern of public key")]
pattern: String,
}
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let args = Args::parse();
let mut client =
libvanity::vanity::vanity_service_client::VanityServiceClient::connect(args.endpoint)
.await?;
let mut request = VanityRequest::default();
request.pattern = args.pattern;
let response = client.request_vanity(request).await?.into_inner();
println!("{}", response.result);
Ok(())
}