go-chain

command module
v0.0.0-...-820de1c Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2018 License: MIT Imports: 9 Imported by: 0

README

Go Report Card GoDoc

This is my personal project to get into the Go programming language (Golang) for the first time. You should not use this Blockchain or Client, except if you want to have some fun! 🤙

Checklist

  • Hash & verify blocks
  • Add Blocks to Blockchain
  • Validate Blockchain
  • Real Mining with Dfficulty (nonce)
  • Transaction Pool & Add Transactions to Blocks
  • Client API
  • Error Management
  • > 90% Test Coverage
  • Wallets
  • P2P-Sync

Have fun ❤️ and give feedback!

Known issues

  • For the purpose of this project, I didn't implement a project structure pattern, like package oriented design. The packages are not designed to be used outside of this project.
  • It's not considered good practice to pack all types in a common /types folder, but it was my first attempt in order to avoid dependency cycles.

Start client

Run make run

Currently it just runs as a simulation and therefore resets the state with every new run.

It will log the output to stdout, so you'll be seeing what is going on in your console. Errors will be written into the errors.log and the current state of the blockchain persisted in state.json. Both files are generated in the root folder.

Make API requests

There is a really small API (without validation) just to get the current state and post new transactions from outside the client.

GET http://localhost:3001/blockchain

Response will be with content-type: application/json

POST http://localhost:3001/transaction

Body (content-type: application/json):

{
  "from": "any string",
  "to": "any string",
  "amount": "any integer"
}

Testing

Run make test

Other useful commands

make linter make test-coverage-report

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
Package api offers a simple REST for other applications.
Package api offers a simple REST for other applications.
Package blockchain contains the "Blockchain" struct that holds all mined blocks.
Package blockchain contains the "Blockchain" struct that holds all mined blocks.
Package crypto contains helper functions related to cryptography.
Package crypto contains helper functions related to cryptography.
Package miner implements the worker which adds valid transactions to a block and finally to the blockchain.
Package miner implements the worker which adds valid transactions to a block and finally to the blockchain.
Package transactions contains the "Transaction" struct and the Transaction Pool.
Package transactions contains the "Transaction" struct and the Transaction Pool.
Package types contains types like structs and interfaces that are commonly used in go-chain.
Package types contains types like structs and interfaces that are commonly used in go-chain.
Package wallet takes care of the key management and the signing of transactions.
Package wallet takes care of the key management and the signing of transactions.

Jump to

Keyboard shortcuts

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