An open API service indexing awesome lists of open source software.

https://github.com/hardworking-toptal-dev/pos-rust

Proof of stake in rust
https://github.com/hardworking-toptal-dev/pos-rust

proof-of-stake rust

Last synced: 6 months ago
JSON representation

Proof of stake in rust

Awesome Lists containing this project

README

          

# Building Proof of Stake in Rust

A tutorial for building a Proof of Stake blockchain in Rust: https://medium.com/emcthye/e76c51f593e9

Start using

```bash
RUST_LOG=info cargo run
```

This starts the client locally. The blockchain is not persisted anywhere.

You can start it in multiple terminals to get multiple connected peer-to-peer clients.

In each client, you can enter the following commands:

* `ls p` - list peers
* `ls c` - print local chain
* `create b $data` - `$data` is just a string here - this creates (mines) a new block with the data entry `$data` and broadcasts it

Once a block is created by a node, it's broadcasted and the blockchain in all other nodes is updated (if it's a valid block).

On startup, a node asks another node on the network for their blockchain and, if it's valid and longer than the current local blockchain, it updates it's own chain to the longest one it receives.

This is a VERY overly simplified, offline-running, highly inefficient and insecure blockchain implementation. If a node gets out of sync, it's broken. This is an example for showing some of the concepts behind building a blockchain system in Rust, so it shouldn't be used anywhere near a production scenario, but you can have fun with it and learn something. :)