From 7f91412ddf3895214a8b56ac520ea7a60c0d24a1 Mon Sep 17 00:00:00 2001 From: Yigit Sever Date: Thu, 15 Apr 2021 00:32:28 +0300 Subject: [WIP] Add template support --- src/handlers.rs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'src/handlers.rs') diff --git a/src/handlers.rs b/src/handlers.rs index a8c9947..b3a6fa8 100644 --- a/src/handlers.rs +++ b/src/handlers.rs @@ -1,5 +1,6 @@ -/// API handlers, the ends of each filter chain use aes::Aes128; +/// API handlers, the ends of each filter chain +use askama::Template; use base64; use blake2::{Blake2s, Digest}; use block_modes::block_padding::Pkcs7; @@ -599,3 +600,19 @@ fn authorize_proposer(jwt_token: String, user_pem: &String) -> Result { + title: &'a str, + body: &'a str, +} + +pub async fn welcome_handler() -> Result { + let template = WelcomeTemplate { + title: "Welcome", + body: "To The Bookstore!", + }; + let res = template.render().unwrap(); + Ok(warp::reply::html(res)) +} -- cgit v1.2.3-70-g09d2 From ca9146db3670cac5a82a3b89b998eee12ff27b44 Mon Sep 17 00:00:00 2001 From: Yigit Sever Date: Thu, 15 Apr 2021 03:40:20 +0300 Subject: shed unused function --- src/handlers.rs | 11 ----------- 1 file changed, 11 deletions(-) (limited to 'src/handlers.rs') diff --git a/src/handlers.rs b/src/handlers.rs index b3a6fa8..7135190 100644 --- a/src/handlers.rs +++ b/src/handlers.rs @@ -194,17 +194,6 @@ pub async fn authenticate_user( Ok(warp::reply::with_status(res_json, StatusCode::CREATED)) } -// fn shed_pem_header_footer(maybe_key: String) -> Result, String> { -// let der_encoded = maybe_key -// .lines() -// .filter(|line| !line.starts_with("-")) -// .fold(String::new(), |mut data, line| { -// data.push_str(&line); -// data -// }); -// Ok(base64::decode(&der_encoded).expect("failed to decode base64 content")) -// } - /// GET /transaction /// Returns JSON array of transactions /// Cannot fail -- cgit v1.2.3-70-g09d2 From 77b99f7d3a8747f562f2b8f1e8df551aafea1b28 Mon Sep 17 00:00:00 2001 From: Yigit Sever Date: Thu, 15 Apr 2021 13:35:06 +0300 Subject: Remove lorems and inpsumses --- site/content/block_docs.md | 27 ++++++++++-- site/content/register_docs.md | 51 +++++++++++----------- site/content/transaction_docs.md | 23 ++++++++-- site/public/block-docs/index.html | 49 +++++++++++++++++++-- site/public/register-docs/index.html | 75 ++++++++++++--------------------- site/public/search_index.en.js | 2 +- site/public/transaction-docs/index.html | 47 ++++++++++++++++++--- src/handlers.rs | 2 +- src/schema.rs | 2 +- 9 files changed, 183 insertions(+), 95 deletions(-) (limited to 'src/handlers.rs') diff --git a/site/content/block_docs.md b/site/content/block_docs.md index 26803bd..4227f26 100644 --- a/site/content/block_docs.md +++ b/site/content/block_docs.md @@ -4,8 +4,27 @@ description = "Block Documentation" weight = 2 +++ -Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod -tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At -vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd -ubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. +A block that was proposed to commit Transactions in `transaction_list` to the +ledger with a nonce that made `hash` valid; 6 zeroes at the left hand side of the +hash (24 bytes). +We are _mining_ using [blake2s](https://www.blake2.net/) algorithm, which produces 256 bit hashes. Hash/second is roughly 20x10^3 on my machine, a new block can be mined in around 4-6 minutes. + +# Requests + +## GET +A HTTP `GET` request to [/block](/block) endpoint will return the latest mined block. + +## POST + +A HTTP `POST` request with Authorization using JWT will allow you to propose your own blocks. + +# Fields +``` +transaction_list: [array of Fingerprints] +nonce: unsigned 32-bit integer +timestamp: ISO 8601 T