go-chain

module
v0.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 31, 2021 License: MIT

README

Go Chain !

A simple blockchain built with inspiration from geth

API Reference Go Report Card CI

Story

Supported
  • Genesis
    • Initializes blockchain from genesis.json
    • creates block 0 from genesis.json data
  • State
  • Transactions
  • Hashing
  • Blocks
    • Validate blocks
    • Mine blocks
  • Http Server
  • Node
    • Peers
    • Sync
  • Wallets
  • LevelDB
    • Stores the blocks against hash
    • Has an index to point block number against hash. Iterator is run on this index
Todo
  • Websockets
  • GRPC
  • Concurrency checks
  • Proof of stake
  • Incoming longer block
  • Persist State
  • Misc items
    • Transactions
      • Block txn from zero address
      • Increment txn nonce for signer
    • Wallet
      • Import private key
    • Signer
      • Implement better way to sign the transactions
    • Node
      • Node Version
      • Sync should happen only after the blocks are synced first time
    • Miner
      • Isolate miner from regular nodes
  • ...??
  • Fix TODO comments

Development

go build ./cmd/go-chain/...
./go-chain --help

Testing

go test -coverprofile=coverage.out ./...
go tool cover -html=coverage.out
go tool cover -func coverage.out | grep total | awk '{print substr($3, 1, length($3)-1)}'

Quick hacks

If you want to view database files

mkdir .database
cd ~/Libaray
ln -s ../../pet-project/blockchain/.database go-chain

Demo

Run console

./go-chain run

Create Wallet

./go-chain wallet new-account
./go-chain wallet print-pk --address="0xdd6b4d532aad2814bf5ea2bcc5e8939294857e6c"

Add Txn

Chain console should be running when transaction commands are called

./go-chain  tx add --from="0xdd6b4d532aad2814bf5ea2bcc5e8939294857e6c" --to="0x054b08ac0c3233efe965a6f24071de1353955e59" --value=50 --data="test"

Directories

Path Synopsis
cmd
db

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL