defunkydrummer / legochain

Simple educational blockchain in Common LIsp

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

legochain

What is this?

This simple program implements a working blockchain class (based on block mining with a difficulty level) plus a very simple "peer to peer" protocol that enables two or more servers to talk to each other and send/receive their blockchains, based on TCP sockets.

This is a simple project with the following goals, either:

Goal A

To show newcomers to Common Lisp, an example of how to implement something not so simple but not too complex, like a blockchain, that would involve the use of:

The code is written with as many comments as possible, and is as clear as I can manage to. The aim was not performance, nor production-quality, but educational value.

You can start by taking a look at legochain.lisp and then to peertopeer.lisp

Goal B

  • To show seasoned CL developers who still haven't yet found out what is a blockchain, block mining, and the "nonce" values, a simple answer by looking at the code.

Supported features

  • Add any kind of data to the block's payload. You only need to define the encoding for the payload using conspack:defencoding (see the code)
  • Verification of one blockchain against other, rejecting invalid blockchains
  • Verification of the continuity (soundness) of each blocks' hash value and sequence value

Peer to peer supported operations:

  • Send blockchain to peer
  • Request blockchain from peer
  • Say "hi" to peer.

You can start many peers from your same machine so you can experiment adding more features to the code.

How to install (for newcomers to CL)

  • Install Portacle, the portable Common Lisp environent.
  • Clone this project into the projects subdirectory under the portacle root directory, so you have it into /portacle/projects/legochain.
  • Start portacle
  • Write (ql:quickload "legochain") to load the program.
  • All the functions are in package "legochain".
  • Try (legochain::servers-test 9000 9001) to make two blockchain servers talk to each other (a simple demo.)

Author

Flavio Egoavil aka D e f u n k y d r u m m e r

License MIT

Hacking

I'm always open to pull requests that can make the code more readable or more educational!

About

Simple educational blockchain in Common LIsp


Languages

Language:Common Lisp 100.0%