diff options
author | Yigit Sever | 2021-04-12 05:32:53 +0300 |
---|---|---|
committer | Yigit Sever | 2021-04-12 05:32:53 +0300 |
commit | 44d21b676f90a2fc8b255eb9c1393e53f40c9daa (patch) | |
tree | edfadfd279dc9fcfaa6c27f819c7f0e69d14599c /src/custom_filters.rs | |
parent | 6c0345ecda5e46da88bc6ca513a28c648c29833c (diff) | |
download | gradecoin-44d21b676f90a2fc8b255eb9c1393e53f40c9daa.tar.gz gradecoin-44d21b676f90a2fc8b255eb9c1393e53f40c9daa.tar.bz2 gradecoin-44d21b676f90a2fc8b255eb9c1393e53f40c9daa.zip |
Implement proof-of-work
Using blacke2s: https://docs.rs/blake2/0.9.1/blake2/
Using this guy's hash checker https://gist.github.com/gkbrk/2e4835e3a17b3fb6e1e7
blacke2s with 5 bits 0 can mine a block between 20 seconds to 359 during
my tests, hope it'll be fun
Diffstat (limited to 'src/custom_filters.rs')
-rw-r--r-- | src/custom_filters.rs | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/src/custom_filters.rs b/src/custom_filters.rs index 0806c6d..315ba4a 100644 --- a/src/custom_filters.rs +++ b/src/custom_filters.rs | |||
@@ -1,10 +1,7 @@ | |||
1 | // Common filters ment to be shared between many endpoints | 1 | use gradecoin::schema::{AuthRequest, Block, Db, Transaction}; |
2 | |||
3 | use std::convert::Infallible; | 2 | use std::convert::Infallible; |
4 | use warp::{Filter, Rejection}; | 3 | use warp::{Filter, Rejection}; |
5 | 4 | ||
6 | use crate::schema::{Block, Db, Transaction, AuthRequest}; | ||
7 | |||
8 | // Database context for routes | 5 | // Database context for routes |
9 | pub fn with_db(db: Db) -> impl Filter<Extract = (Db,), Error = Infallible> + Clone { | 6 | pub fn with_db(db: Db) -> impl Filter<Extract = (Db,), Error = Infallible> + Clone { |
10 | warp::any().map(move || db.clone()) | 7 | warp::any().map(move || db.clone()) |
@@ -12,7 +9,8 @@ pub fn with_db(db: Db) -> impl Filter<Extract = (Db,), Error = Infallible> + Clo | |||
12 | 9 | ||
13 | // Accept only json encoded User body and reject big payloads | 10 | // Accept only json encoded User body and reject big payloads |
14 | // TODO: find a good limit for this, (=e2482057; 8 char String + rsa pem) <11-04-21, yigit> // | 11 | // TODO: find a good limit for this, (=e2482057; 8 char String + rsa pem) <11-04-21, yigit> // |
15 | pub fn auth_request_json_body() -> impl Filter<Extract = (AuthRequest,), Error = Rejection> + Clone { | 12 | pub fn auth_request_json_body() -> impl Filter<Extract = (AuthRequest,), Error = Rejection> + Clone |
13 | { | ||
16 | warp::body::content_length_limit(1024 * 32).and(warp::body::json()) | 14 | warp::body::content_length_limit(1024 * 32).and(warp::body::json()) |
17 | } | 15 | } |
18 | 16 | ||