leoroullois / blockchain

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Fake Blockchain implementation

Installation

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.

API

There is different routes to interact with the blockchain :

  • POST /mine_block: Mine a block

Mine block Mine block

  • GET /get_chain : returns all the blocks of the blockchain

Get chain

  • GET /valid : Checks if the blockchain is valid

Valid

  • GET /create-fake-block : Create a fake non-valid block

Create fake block

  • GET /peers : Show number of peers

Peers

MCL

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/")

Development

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

About


Languages

Language:Python 92.2%Language:Dockerfile 6.0%Language:Shell 1.8%