Simple distributed blockchain experiment written in Crystal
> git clone firstname.lastname@example.org:oguzbilgic/zincir-crystal.git ... > shards install ... > shards build --release Dependencies are satisfied Building: zincird
> ./bin/zincird --help Usage: zincir [arguments] -s IP, --seed-ip=IP First node to connect, TestNet by default -i IP, --host-ip=IP Node's public ip, If the node is public -p PORT, --port=PORT Node's public port, If the node is public -l, --local-net Prevents node from connecting to public nodes -w, --web Start web server without making the node public -m, --mine Enable mining -h, --help Show this help -v, --version Show node version
> ./bin/zincird --mine Connecting to testnet.zincir.xyz:9147 Added <1-0878bff02..ec7> 1544946023 ...
Node will connect to
TestNet by default and sync the blockchain, before mining. Blockchain will be cached in
> ./bin/zincird --ip mynode.mywebsite.com --port 1234 --mine Connecting to testnet.zincir.xyz:9147 Added <1-0878bff02..ec7> 1544946023 ...
In public mode, node will advertise it's ip and host to the network for other nodes to connect. Therefore, node needs to be publicly accessible with the provided ip and port configuration
- Read and add cached blocks from
.blocks/folder to blockchain. Whenever a new block is added to the chain, store it in the
--local-netis set, connect to seed host (testnet by default, can be updated with
- Compare our last block to network's last block
- Find the highest common block between network and local
- If network has a higher last block download all blocks between
common_blockand network's last block
- If our last block is higher, broadcast all blocks between the
common_blockand our last block
- Once the network download or broadcast is complete, wait for 5 seconds and compare local and network last block's to ensure network and local is synced
--portoption is provided start local web server
--host-ipoption is provided start public web server and broadcast our ip to all the connected hosts.
--mineoption is set start the miner to mine new blocks. When a new block is mined broadcast it to network
> crystal spec ...
- almost 3 years ago
- December 6, 2018
Thu, 21 Oct 2021 21:29:18 GMT