From 33e9c6c73fea420d76e1fb202d42763ad1819534 Mon Sep 17 00:00:00 2001 From: Andrew Dirksen Date: Mon, 13 May 2019 10:23:00 -0700 Subject: [PATCH] Get syntax highlighting in readme. --- Cargo.toml | 2 +- readme.md | 10 +++++----- src/lib.rs | 10 +++++----- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 90e7eb7..dab7363 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pow" -version = "0.1.3" +version = "0.1.4" authors = ["Andrew Dirksen "] description = """ Generate or verify sha256 based proofs of work over arbitrary typed data. diff --git a/readme.md b/readme.md index 84ae47b..76fc88d 100644 --- a/readme.md +++ b/readme.md @@ -8,7 +8,7 @@ Any type that implementes serde::Deserialize can be tagged with a proof of work. Prove we did work targeting a phrase. -``` +```rust use pow::Pow; // very easy mode @@ -21,7 +21,7 @@ assert!(pw.score(&phrase).unwrap() >= difficulty); Prove more difficult work. This time targeting a time. -``` +```rust // more diffcult, takes around 100_000 hashes to generate proof let difficulty = u128::max_value() - u128::max_value() / 100_000; @@ -41,7 +41,7 @@ of work blockchains. In other words: -``` +```rust fn score(target: &T, pow_tag: &Pow) -> u128 { let bytes = serialize(&SALT) + serialize(target) + serialize(pow_tag); let hash = sha256(&bytes); @@ -64,7 +64,7 @@ Difficulty settings are usually best adjusted dynamically a la bitcoin. To manually select a difficulty, choose the average number of hashes required. -``` +```rust fn difficulty(average: u128) -> u128 { debug_assert_ne!(average, 0, "It is impossible to prove work in zero attempts."); let m = u128::max_value(); @@ -75,7 +75,7 @@ fn difficulty(average: u128) -> u128 { Conversely, to calculate probable number of hashes required to satisfy a given minimum difficulty. -``` +```rust fn average(difficulty: u128) -> u128 { let m = u128::max_value(); if difficulty == m { diff --git a/src/lib.rs b/src/lib.rs index 5896291..6de49be 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -6,7 +6,7 @@ //! //! Prove we did work targeting a phrase. //! -//! ``` +//! ```rust //! use pow::Pow; //! //! // very easy mode @@ -19,7 +19,7 @@ //! //! Prove more difficult work. This time targeting a time. //! -//! ``` +//! ```rust //! # fn get_unix_time_seconds() -> u64 { //! # use std::time::{Duration, SystemTime}; //! # SystemTime::now().duration_since(SystemTime::UNIX_EPOCH).unwrap().as_secs() @@ -45,7 +45,7 @@ //! //! In other words: //! -//! ``` +//! ```rust //! # use serde::Serialize; //! # use pow::Pow; //! # use core::any::Any; @@ -75,7 +75,7 @@ //! //! To manually select a difficulty, choose the average number of hashes required. //! -//! ``` +//! ```rust //! fn difficulty(average: u128) -> u128 { //! debug_assert_ne!(average, 0, "It is impossible to prove work in zero attempts."); //! let m = u128::max_value(); @@ -86,7 +86,7 @@ //! Conversely, to calculate probable number of hashes required to satisfy a given minimum //! difficulty. //! -//! ``` +//! ```rust //! fn average(difficulty: u128) -> u128 { //! let m = u128::max_value(); //! if difficulty == m {