Skip to content

Commit

Permalink
#1 fix some error
Browse files Browse the repository at this point in the history
  • Loading branch information
VN Fosly authored and VN Fosly committed Aug 17, 2023
1 parent 1bbf523 commit f8a78e1
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
19 changes: 9 additions & 10 deletions src/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,16 @@ use std::collections::HashMap;
use std::time::{SystemTime, UNIX_EPOCH};
use block::{Block as Block};
use block::{BlockData as Data};
use block::{ChainFLD as FLD};
pub use block::{ChainFLD as ChainFLD};
use block::{providerData as Provider};

impl FLD {
pub fn new() -> Self {
pub trait FLD {
fn new() -> Self;
fn initialization(&mut self, fromAddr: String, toAddr: String);
}

impl FLD for ChainFLD {
fn new() -> Self {
Self {
blocks: vec![],
provider: Provider {
Expand All @@ -24,11 +29,8 @@ impl FLD {
}
}

pub fn hash2binary(hash: &[u8]) {

}

pub fn initialization(&mut self, fromAddr: String, toAddr: String) {
fn initialization(&mut self, fromAddr: String, toAddr: String) {
let mut block: Vec<HashMap<String, Block>> = Vec::new();
let mut id: HashMap<String, Block> = HashMap::new();
id.insert(String::from("id"), Block::Id(hash(
Expand Down Expand Up @@ -69,8 +71,5 @@ impl FLD {
self.blocks.push(block);
}

pub fn isValid(&self, block: &Vec<HashMap<String, Block>>, previous_block: &Vec<HashMap<String, Block>>) {

}

}
2 changes: 1 addition & 1 deletion src/chain/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ pub enum Block {
BlockData(BlockData)
}


#[derive(Debug,Clone)]
pub struct ChainFLD {
pub blocks: Vec<Vec<HashMap<String, Block>>>,
pub(crate) provider: providerData
Expand Down
6 changes: 4 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
mod math;
mod chain;

use chain::{FLD as FLD};
use chain::{ChainFLD as ChainFLD};
use math::{sha256 as hash};

fn main() {
let res = hash("hello".to_string());
println!("Result: {}", res);
let blockChain = ChainFLD::new();
println!("{:?}", blockChain);
}

0 comments on commit f8a78e1

Please sign in to comment.