Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/huumn/crisp
A cryptocurrency written in Lisp (Chez Scheme)
https://github.com/huumn/crisp
blockchain chezscheme lisp scheme
Last synced: 4 days ago
JSON representation
A cryptocurrency written in Lisp (Chez Scheme)
- Host: GitHub
- URL: https://github.com/huumn/crisp
- Owner: huumn
- Created: 2020-05-06T02:04:34.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2021-03-01T22:18:36.000Z (almost 4 years ago)
- Last Synced: 2024-10-06T06:42:50.989Z (3 months ago)
- Topics: blockchain, chezscheme, lisp, scheme
- Language: Scala
- Homepage:
- Size: 21.5 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Crisp is a cryptocurrency written in Lisp. As of this writing, it's a toy blockchain written in Chez Scheme.
## Goals
1. Make Crisp a robust blockchain implementation written in Lisp that also uses Lisp as the transaction language.
2. Experiment with the transaction language such that it provides features unavailable in existing blockchains## Control
Crisp listens on a TCP port for control commands. Commands can be sent pretty naturally with telnet as commands are framed by the delimiter `\r\n`:
```
> blocks
> [{"index":0,"prev-hash":"","timestamp":1465154705,"data":"Genisis Block."}]
```A command name and its arguments are delimited with spaces:
```
> peer-add 127.0.0.1 9998
> OK
```#### Control Commands
| command | returns |
| ------------- | ------------- |
| blocks | json array of blocks |
| block-mine [msg] | newly mined block as json |
| block-last | the last block mined |
| peers | json array of peers as ip:port |
| peer-add ip port | OK |
| echo msg | msg |## Peer Gossip
Crisp peers gossip over TCP. Messages are encoded as ascii-length-prefixed JSON, where the message length and the messages themselves are delimited with `\r\n`. The JSON messages contain both a `type` and `data` field. When a peer asks another peer for its last block, the message looks like the following:
```
"31\r\n{\"type\":\"last-block\",\"data\":\"\"}\r\n"
```#### Peer Message types and data
| type | data |
| --- | --- |
|last-block| no data expected|
|last-block-resp | json encoded block |
|blocks | no data expected |
|blocks-resp | json array of blocks|## Consensus
The valid chain with the most cumulative work always wins. Because we don't yet have transactions, valid here only means the chain itself is a valid blockchain. That is, the blocks are "linked" with the correct hash "pointers," and the timestamps between blocks is reasonable.
## Running
For the time being Crisp uses [ravensc.com](http://ravensc.com) for package control and uses [suv](http://github.com/huumn/suv) for io which you'll have to clone and build manually. The full process from scratch, assuming you already have [chez](https://github.com/cisco/ChezScheme) and aren't on Windows:
```
$ curl -L http://ravensc.com/install | scheme
$ git clone [email protected]:huumn/crisp.git
$ cd crisp
$ raven install
$ cd lib
$ git clone [email protected]:huumn/suv.git
$ cd suv
$ cc -o3 -fPIC -shared c/suv.c -luv -o libsuv.so
$ cd ../..
$ scheme --script main.sc
```You should then be able to connect to your Crisp node via telnet:
```
$ telnet 127.0.0.1 7777
echo hello
hello
blocks
[{"index":0,"prev-hash":"","timestamp":1465154705,"data":"Genisis Block."}]
```