Skip to content

ebsnet/blockchain

Repository files navigation

Blockchain

Hackaburg

This repository is part of our challenge at Hackaburg 2018. To make use of the CI and CD features, you should use the gitflow workflow. Every commit made on master or develop will be build using Travis CI. Tagged commits, that match the regular expression ^v\d+\.\d+\.\d+.*$ (e.g v0.1.0) will be built and uploaded to the release page. After uploading a new release, a webhook will be triggered and the new build is automatically deployed on hackaburg.ebsnet.de.

Repository Structure

lib

Libraries that offer shared utility methods.

lib/blockchain

Generic PoW blockchain library

lib/client

HTTP client library to communicate with the web service

lib/cryptography

Cryptography functions for handling key pairs, secure memory management, signing and verifying data

lib/data

Exposes a concrete blockchain,

Building The Components

This project was developed using the Rust nightly compiler from 2018-02-14. Newer versions should work as well. To install this specific version run

rustup install nightly-2018-02-14

Alternatively everything can be build inside a Docker container using the docker_build_musl.sh and docker_build_glibc.sh scripts.

Logging

Log levels are handled via the RUST_LOG environment variable. The default log level is error. To view info logs (which is recommended), the environment variable needs to be set. It has the following structure:

RUST_LOG="<component>=<level>"
RUST_LOG="<component1>=<level>,<component2>=<level>"

Component being the name of a crate. The environment variable can either be set globally for the current shell session using export RUST_LOG="webservice=info" or by starting a component like this: RUST_LOG="webservice=info ./webservice"

The following line will set the log level for all components of this repository in the current shell session:

export RUST_LOG="webservice=info,tx_generator=info,invoice_generator=info"

Usage example

  1. Start the web service: (this will start a web server listening on localhost:1337, persisting the blockchain to ./blockchain.dat; for more information view the help dialog by passing the --help flag)

    RUST_LOG="webservice=info" ./webservice
    
  2. Generate a key pair for the user:

    RUST_LOG="tx_generator=info" ./tx_generator generate_keypair -p user.key
    
  3. Export the user's public key:

    RUST_LOG="tx_generator=info" ./tx_generator export_public_key -k user.key user.pub
    
  4. Generate a key pair for the billing party:

    RUST_LOG="invoice_generator=info" ./invoice_generator -k billing.key generate_keypair
    
  5. Initialize billing for the user:

    RUST_LOG="invoice_generator=info" ./invoice_generator -k billing.key initialize_billing -h http://localhost:1337/ --publickey user.pub
    
  6. Generate usage transactions:

    RUST_LOG="tx_generator=info" ./tx_generator generate_transaction -h http://localhost:1337 <usage> -k user.key
    
  7. Generate invoice for user:

    RUST_LOG="invoice_generator=info" ./invoice_generator -k billing.key create_invoice --publickey user.pub -h http://localhost:1337/
    

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published