Clone the repository :
git clone https://github.com/leoroullois/blockchain.git && cd blockchain
Start the server on your machine :
docker compose up -d
The server will listen on http://localhost:5000
.
There is different routes to interact with the blockchain :
- POST
/mine_block
: Mine a block
- GET
/get_chain
: returns all the blocks of the blockchain
- GET
/valid
: Checks if the blockchain is valid
- GET
/create-fake-block
: Create a fake non-valid block
- GET
/peers
: Show number of peers
MCL library and his python wrapper is installed by default in the docker container.
For testing if the library is successfully installed, first get a shell inside the container :
docker compose exec -ti blockchain /bin/bash
Then, run this command :
cd /app/mcl && chmod +x tests.sh && ./tests.sh
Before importing something from the library, you need to set this code :
import sys
sys.path.insert(1, "/lib/mcl-python/")
After making changes in the codebase you need to restart the server with this command:
docker compose restart
To see container logs, type :
docker compose logs -f blockchain