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
- Fork the repo
- Change
BloodSugarLevel
in the block
struct in blockchain.go
to whatever data you want to track
- Update the
message
struct in webserver.go
for your data