Skip to content

Blockchain with 5 separate ports (nodes) - Transaction, Consensus, Broadcasting nodes and blocks

Notifications You must be signed in to change notification settings

vince15dk/blockchain

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Blockchain Node.js

This app is to emulate blockchain ecosystem in node.js

node.js로 구현한 블록체인 애플리케이션

Running 5 diffrenet local servers(ports) declared in package.json
Each server(port) handles the blockchain process as if being chained as series of the nodes in the real world blockchain application.

Each end point API can be tested by postman and browser (UI page added by Angular)

  • /transaction-broadcast (postman) -- transaction of bitcoin on pending state
  • /register-and-broadcast-node (postman) -- connection of servers(nodes)
  • /mine (on browser) -- mining successfully carried
  • /consensus (on browser) -- addition of new server to the current nodes ecosystem
  • /block-explorer (on browser) -- UI page

Enjoy!

install npm dependencies

npm install

open 5 separate bashes to run each node on different port from 3001~3005

npm run node_1
npm run node_2
npm run node_3
npm run node_4
npm run node_5

Get /localhost:3001/blockchain
  • Explore the current state of blockchain

postman Rest API Control

Post /localhost:3001/register-and-broadcast-node 

Post /transaction-broadcast
  • Postman with JSON body {"amount":1000, sender:"id", recipient:"id"} -- send bitcoin
  • This automatically adds the transaction(on pending) to all of the nodes

Browser
Get /mine
  • Carrying a succesful mining process as committing all of the transactions

Browser
Get //localhost:{{new port}}/consensus
  • Add the past record of all blockchains to the new node and share the current state of other nodes
  • Make sure to register a new node to other nodes beforhand, executing "/localhost:3001/register-and-broadcast-node"

Browser

Get /block-explorer
  • You can explore the blocks in search of the transaction record, hash, and user history

About

Blockchain with 5 separate ports (nodes) - Transaction, Consensus, Broadcasting nodes and blocks

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published