mirror of
https://github.com/mCaptcha/mCaptcha.git
synced 2026-02-11 10:05:41 +00:00
duplicate email check and address clippy warnings
This commit is contained in:
@@ -28,35 +28,33 @@
|
||||
//!
|
||||
//! generate proof-of-work
|
||||
//! ```rust
|
||||
//! fn main() {
|
||||
//! use mcaptcha_browser::*;
|
||||
//! use pow_sha256::*;
|
||||
//! use mcaptcha_browser::*;
|
||||
//! use pow_sha256::*;
|
||||
//!
|
||||
//!
|
||||
//! // salt using which PoW should be computed
|
||||
//! const SALT: &str = "yrandomsaltisnotlongenoug";
|
||||
//! // one-time phrase over which PoW should be computed
|
||||
//! const PHRASE: &str = "ironmansucks";
|
||||
//! // and the difficulty factor
|
||||
//! const DIFFICULTY: u32 = 1000;
|
||||
//! // salt using which PoW should be computed
|
||||
//! const SALT: &str = "yrandomsaltisnotlongenoug";
|
||||
//! // one-time phrase over which PoW should be computed
|
||||
//! const PHRASE: &str = "ironmansucks";
|
||||
//! // and the difficulty factor
|
||||
//! const DIFFICULTY: u32 = 1000;
|
||||
//!
|
||||
//! // currently gen_pow() returns a JSON formated string to better communicate
|
||||
//! // with JavaScript. See [PoW<T>][pow_sha256::PoW] for schema
|
||||
//! let serialised_work = gen_pow(SALT.into(), PHRASE.into(), DIFFICULTY);
|
||||
//! // currently gen_pow() returns a JSON formated string to better communicate
|
||||
//! // with JavaScript. See [PoW<T>][pow_sha256::PoW] for schema
|
||||
//! let serialised_work = gen_pow(SALT.into(), PHRASE.into(), DIFFICULTY);
|
||||
//!
|
||||
//!
|
||||
//! let work: Work = serde_json::from_str(&serialised_work).unwrap();
|
||||
//! let work: Work = serde_json::from_str(&serialised_work).unwrap();
|
||||
//!
|
||||
//! let work = PoWBuilder::default()
|
||||
//! .result(work.result)
|
||||
//! .nonce(work.nonce)
|
||||
//! .build()
|
||||
//! .unwrap();
|
||||
//! let work = PoWBuilder::default()
|
||||
//! .result(work.result)
|
||||
//! .nonce(work.nonce)
|
||||
//! .build()
|
||||
//! .unwrap();
|
||||
//!
|
||||
//! let config = ConfigBuilder::default().salt(SALT.into()).build().unwrap();
|
||||
//! assert!(config.is_valid_proof(&work, &PHRASE.to_string()));
|
||||
//! assert!(config.is_sufficient_difficulty(&work, DIFFICULTY));
|
||||
//! }
|
||||
//! let config = ConfigBuilder::default().salt(SALT.into()).build().unwrap();
|
||||
//! assert!(config.is_valid_proof(&work, &PHRASE.to_string()));
|
||||
//! assert!(config.is_sufficient_difficulty(&work, DIFFICULTY));
|
||||
//! ```
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
@@ -124,8 +122,7 @@ pub fn gen_pow(salt: String, phrase: String, difficulty_factor: u32) -> String {
|
||||
let work = config.prove_work(&phrase, difficulty_factor).unwrap();
|
||||
let work: Work = work.into();
|
||||
|
||||
let payload = serde_json::to_string(&work).unwrap();
|
||||
payload
|
||||
serde_json::to_string(&work).unwrap()
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
Reference in New Issue
Block a user