This project is a 1:1 port of the Python blockchain implementation in Daniel van Flymen's article
Learn Blockchains by Building One
- Comments are taken from original implementation
- Class and function names match original where appropriate, except for naming convention (
CamelCase
instead ofsnake_case
)
- Docker >= 17.05.0
- docker-compose >= 1.13.0
$ ./bootstrap.sh
Start a docker container:
$ docker-compose up -d
Then, enter a container shell:
$ ./docker-cmd.sh bash
$ cd build
Compile:
$ ninja
Run tests:
$ ./tests
(to be run outside of the Docker container)
$ ./run-tests.sh
First, start blockchain server in container:
$ docker-compose up -d
$ ./docker-cmd.sh ./build/blockchain-dvf
docker-compose.yml
maps the container port 5000 to port 5000 on the host.
To reset the blockchain, interrupt the server with CTRL-c
and start it again.
$ curl http://localhost:5000/mine
$ curl -X POST --header "Content-Type:application/json" \
--data '{"sender": "abc", "recipient": "def", "amount": 10}' \
http://localhost:5000/transactions/new
$ curl http://localhost:5000/chain
$ curl -X POST --header "Content-Type:application/json" \
--data '{"nodes": ["http://localhost:5001"]}' \
http://localhost:5000/nodes/register
$ curl http://localhost:5000/nodes/resolve