Skip to content

A content sharing platform where a post shared by a user is treated as transaction, and further stored in blocks which are then added to the blockchain. We use proof of work to authenticate a block and consensus is reached accordingly before a block is added to the blockchain.

Notifications You must be signed in to change notification settings

SinghNehal/POST_IT

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PostIT

A blockchain-based application in python.

Instructions to run

$ pip install -r requirements.txt

Starting Blockchain-node and server

export FLASK_APP=node_server.py
flask run --port 8000

image

Now one instance of our blockchain node is now up and running at port 8000.

In another Terminal Window type

python run_app.py

image

The application should be up and running at http://localhost:5000. image

Here are few screenshots for the application :

  1. Posting some content . image

  2. Requesting node to mine .

  • image
  1. Resyncing the chain with updated data image

Now for settting up multiple Nodes , and registering them we will be using the register_with/ We will be using cURL requests to register the nodes at port 8001 and 8002 with the already running 8000.

flask run --port 8000 & flask run --port 8001

curl -X POST \
http://127.0.0.1:8001/register_with \
-H 'Content-Type: application/json' \
-d '{"node_address": "http://127.0.0.1:8000"}'

image

Now node at port 8000 is aware about nodes at port 8001 and 8002. Now there will be an active participation in mining process and sync in all nodes.

Once all of this done, we can run the application , create transactions (post messages via the web interface), and after mining the transactions all the nodes in the network will update the chain. So now even if we will make two transactions , one with port 8000 and second with port 8001 , we will be able to see both transactions in our blockchain. image Transaction 3,4 were done with port 8001, but since it is registered with port 8000 , we will see chain the transactions mentioned with port 8000 , and 8001 mentioned as peer.

We can see the chain of nodes by the following command :

curl -X GET http://localhost:8000/chain

Screenshot of the chain of nodes for out current transactions is : image

About

A content sharing platform where a post shared by a user is treated as transaction, and further stored in blocks which are then added to the blockchain. We use proof of work to authenticate a block and consensus is reached accordingly before a block is added to the blockchain.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published