diff options
author | Yigit Sever | 2021-04-12 05:32:53 +0300 |
---|---|---|
committer | Yigit Sever | 2021-04-12 05:32:53 +0300 |
commit | e0fb91039f34204b2a5c588a95cb3f1789ad2fa7 (patch) | |
tree | 9c38670c348f04c57185639c541a1a93b8cfde2a /src/custom_filters.rs | |
parent | 62aa261e1fd531afd1e5fa7244471d051a78db38 (diff) | |
download | gradecoin-e0fb91039f34204b2a5c588a95cb3f1789ad2fa7.tar.gz gradecoin-e0fb91039f34204b2a5c588a95cb3f1789ad2fa7.tar.bz2 gradecoin-e0fb91039f34204b2a5c588a95cb3f1789ad2fa7.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 | ||