New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More

github.com/josetom/blockchain

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/josetom/blockchain


Version published
Created

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"

FAQs

Package last updated on 31 Jul 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts