aboutsummaryrefslogtreecommitdiffstats
path: root/src/custom_filters.rs
diff options
context:
space:
mode:
authorYigit Sever2021-04-12 05:32:53 +0300
committerYigit Sever2021-04-12 05:32:53 +0300
commit44d21b676f90a2fc8b255eb9c1393e53f40c9daa (patch)
treeedfadfd279dc9fcfaa6c27f819c7f0e69d14599c /src/custom_filters.rs
parent6c0345ecda5e46da88bc6ca513a28c648c29833c (diff)
downloadgradecoin-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.rs8
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 1use gradecoin::schema::{AuthRequest, Block, Db, Transaction};
2
3use std::convert::Infallible; 2use std::convert::Infallible;
4use warp::{Filter, Rejection}; 3use warp::{Filter, Rejection};
5 4
6use crate::schema::{Block, Db, Transaction, AuthRequest};
7
8// Database context for routes 5// Database context for routes
9pub fn with_db(db: Db) -> impl Filter<Extract = (Db,), Error = Infallible> + Clone { 6pub 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> //
15pub fn auth_request_json_body() -> impl Filter<Extract = (AuthRequest,), Error = Rejection> + Clone { 12pub 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