Struct blockchain::Chain
source · pub struct Chain { /* private fields */ }Expand description
A blockchain
Implementations§
source§impl Chain
impl Chain
pub fn new(address: String, difficulty: u32, reward: f32) -> Chain
pub fn get_transactions(&mut self) -> &Vec<Transaction>
pub fn get_transaction(&self, hash: String) -> Option<&Transaction>
pub fn add_transaction(&mut self, from: String, to: String, amount: f32) -> bool
pub fn get_last_hash(&self) -> String
pub fn update_difficulty(&mut self, difficulty: u32) -> bool
pub fn update_reward(&mut self, reward: f32) -> bool
pub fn generate_new_block(&mut self) -> bool
pub fn get_merkle(transactions: Vec<Transaction>) -> String
pub fn proof_of_work(header: &mut BlockHeader)
pub fn hash<T: Serialize>(item: &T) -> String
Trait Implementations§
Auto Trait Implementations§
impl RefUnwindSafe for Chain
impl Send for Chain
impl Sync for Chain
impl Unpin for Chain
impl UnwindSafe for Chain
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more