Giter Club home page Giter Club logo

blockchain-python's Introduction

This is a Python3 implementation of a blockchain.

The purpose of this implementation is to discover possible adaptations of our use case (tokenizing campaigns and storing them in a secure ledger) in the context of a traditional blockchain.

Before getting started

Create a folder on integration cluster OR on your local machine by naming it as blockchain

To install all the necessary libraries make sure that you have following files in your blockchain folder:

  • begin.sh
  • /files/requirements.txt

With using virtualenv:

To install them just run the command below, which:

  • will create your virtualenv with a name blockchain-py3
  • will install all the necessary libraries in your virtualenv
sh begin.sh

To activate your virtualenv:

source blockchain-py3/bin/activate

To deactivate your virtualenv:

deactivate

How to initialize a blockchain node

You can initialize and run your blockchain nodes either on localhost or on cluster:

Version 4 (p2p):

Alt-Text

Activate your virtualenv:

source blockchain-py3/bin/activate

Initialize the first node on integration cluster on master <master_ip>

python node.py

And, initialize other nodes on other machines in the cluster by following the same procedure described above.

Version 5 (p2p and multi-layered networks):

Single-Master configuration:

Alt-Text

Activate your virtualenv:

source blockchain-py3/bin/activate

Initialize the master node on integration cluster on master <master_ip> with 2 different ports (2 separate networks)

python node_multilayer_singlemaster.py master <port_no_1> <port_no_2>

Example:

python node_multilayer_singlemaster.py master 20000 30000

And, initialize other nodes on other machines in the cluster (choose the network by choosing the port among the ports available on master)

python node_multilayer_singlemaster.py slave <port_no_1 OR port_no_2>

Example:

python node_multilayer_singlemaster.py slave 20000

Multiple-Master configuration:

Alt-Text

Activate your virtualenv:

source blockchain-py3/bin/activate

Initialize the first and second master nodes on integration cluster on different machines with 2 different ports for 2 diff. networks

python node_multilayer_multimaster.py master <port_no_1> <port_no_2>

Example:

python node_multilayer_multimaster.py master 20000 30000

And, initialize other nodes on other machines in the cluster (choose the network by choosing the port among the ports available on master)

python node_multilayer_multimaster.py slave <master_ip_1> <master_ip_2> <port_no_1 OR port_no_2>

Example:

python node_multilayer_multimaster.py slave <slave_ip> <master_ip> 20000

How to interact with a blockchain node

Version 4 & 5

After launching the script among node.py OR node_multilayer_singlemaster.py OR node_multilayer_multimaster.py;

You will be able to access to corresponsing node's chain by passing the command:

get chain

to send a hey to peers (connection test):

hey

to get the active peers list:

get peers

to get the network that the node belongs to:

get network

to get the unvalidated transactions list:

get txs

to mine:

mine

to reach a consensus:

consensus

to shut down the node properly:

q

blockchain-python's People

Contributors

emrekaragozoglu avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.