[][src]Crate damn_vuln_blockchain

This is a test blockchain that I build for fun and as the name suggests, it is bloody vulnerable.

This library serves as its building block.

Create a new blockchain

use damn_vuln_blockchain::{ asset::AssetLedger, block::{BlockBuilder, Block}, chain::Chain};

fn main() {
       let chain = Chain::new("My chain"); // crate cahin
  }

Create a block

use damn_vuln_blockchain::{ asset::AssetLedger, block::{BlockBuilder, Block}, chain::Chain};


fn main() {
       let chain = Chain::new("My chain"); // create blockchain
       let peer_id = "Me";
       let mut assets = AssetLedger::generate(peer_id); // generate some assets

       let asset = assets.assets.pop().unwrap();

       // get the last block of a chain
       let prev = chain.get_last_block();

       let block = BlockBuilder::default()
           .set_tx("Me")
           .set_rx("You")
           .set_prev(&prev)
           .set_asset_id(&asset.get_hash())
           .set_validator("Me")
           .build();

       assert!(!block.is_genesis());
       assert_eq!(block.get_tx().unwrap(), "Me");
       assert_eq!(block.get_rx().unwrap(), "You");
}

Re-exports

pub use client::Client;
pub use config::Config;

Modules

asset

Assets are objects that can be transacted on the blockchain

block

the smallest unit/data-structure that can go into the blockchain

chain

Ledger data-structure for the blockchain

client

Client wrapper for p2p communication

config
discovery

Peer management service for synchronising and discovery. The easiest way to interact with the peer management service is with the Network actor.

error

Error datatypes

helpers
logs
payload

Payload datatype that dwb uses

utils