Struct blockchain::Chain
source · pub struct Chain {
pub chain: Vec<Block>,
pub current_transactions: Vec<Transaction>,
pub difficulty: u32,
pub address: String,
pub reward: f32,
}Expand description
A blockchain
Fields§
§chain: Vec<Block>A chain of blocks
current_transactions: Vec<Transaction>A list of transactions
difficulty: u32A current difficulty level of the network
address: StringA blockchain genesis address
reward: f32A block reward
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