From e0dc8c845aae20cacf16d3c442c418430dc3cbb3 Mon Sep 17 00:00:00 2001 From: Jake Hillion Date: Mon, 14 Jun 2021 22:43:43 +0100 Subject: [PATCH] Began adding chain logic --- Cargo.lock | 4 ++++ Cargo.toml | 1 + currency/Cargo.toml | 9 +++++++++ currency/src/lib.rs | 33 +++++++++++++++++++++++++++++++++ 4 files changed, 47 insertions(+) create mode 100644 currency/Cargo.toml create mode 100644 currency/src/lib.rs diff --git a/Cargo.lock b/Cargo.lock index 12542f0..a9d5e2e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,5 +1,9 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. +[[package]] +name = "currency" +version = "0.1.0" + [[package]] name = "farm" version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml index f49f66b..3cf612c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,7 @@ [workspace] members = [ + "currency", "farm", "node", "plot", diff --git a/currency/Cargo.toml b/currency/Cargo.toml new file mode 100644 index 0000000..2ebd259 --- /dev/null +++ b/currency/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "currency" +version = "0.1.0" +authors = ["Jake Hillion "] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/currency/src/lib.rs b/currency/src/lib.rs new file mode 100644 index 0000000..8be666e --- /dev/null +++ b/currency/src/lib.rs @@ -0,0 +1,33 @@ +use std::collections::HashMap; + +type Hash = [u8; 64]; +type Signature = [u8; 64]; +type Address = [u8; 32]; + +type ChainHeight = u64; +type ChainSize = u64; +type Cost = u128; +type ChainIndex = u64; + +pub struct BeaconEntry { + pub prev: Hash, + pub height: ChainHeight, +} + +pub struct ShardEntry { + pub prev: Hash, + pub height: ChainHeight, + + pub transactions: Vec, +} + +pub struct Transaction { + pub address: Address, + pub signature: Signature, +} + +impl Transaction { + fn get_cost(transaction: &Transaction, sizes: HashMap) -> Cost { + todo!() + } +}