blockchain

package module
v0.0.0-...-8818dac Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 17, 2020 License: MIT Imports: 14 Imported by: 0

README

blood-sugar-blockchain

A blockchain where the blocks hold data on blood sugar levels measured in mg/dL

Development

Environment variables

Environment variables are handled using GoDotEnv.

Copy .env.sample to .env and replace the values with your own if needed.

Variables
  • HTTP_PORT: the port the webserver will run on
  • TCP_PORT=9000: the port to run TCP on
  • BASIC_AUTH_USERNAME: the username for basic auth
  • BASIC_AUTH_PASSWORD: the password for basic auth
Running locally
Webserver

You can run the blockchain over HTTP with the webserver. Start the webserver with:

go run cmd/webserver/main.go

Then visit http://localhost:8080 or the port specified in .env.

There is a GET route that returns the full blockchain and a POST route that adds a new block behind basic authentication.

Basic authentication credentials are set in .env.

TCP Network

You can also run the blockchain over a TCP network that accepts incoming requests. Start the network with:

go run cmd/network/main.go

You can connect to the network with:

nc localhost 9000

Change the port to what you have set in your .env file.

Tracking your own data

  1. Fork the repo
  2. Change BloodSugarLevel in the block struct in blockchain.go to whatever data you want to track
  3. Update the message struct in webserver.go for your data

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RunNetwork

func RunNetwork()

RunNetwork creates and starts the TCP server.

func RunWebserver

func RunWebserver() error

RunWebserver creates and runs the webserver.

Types

This section is empty.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL