FPierre / simple-blockchain

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Simple blockchain

Shamefully inspired from this article (code).

Principle

  • When connected to peers, it's become an node.
  • When generates a new block, node broadcasts it to others connected peers.
  • When a node connects to a new peer it querys for the latest block.
  • When a node encounters a block that has an index larger than the current known block, it either adds the block the its current chain or querys for the full blockchain.

HTTP methods

  • Get all blocks: GET /blocks
  • Start mining: POST /mine
  • Get all connected peers: GET /peers
  • Connect to peers: POST /peers

Get started

Run HTTP and P2P servers:

$ yarn run dev

Tests

Run tests:

$ yarn run test

About


Languages

Language:JavaScript 100.0%