Skip to content

Latest commit

 

History

History
105 lines (94 loc) · 3.98 KB

getting-started.org

File metadata and controls

105 lines (94 loc) · 3.98 KB

Getting started

Prerequisites

Operating systemLinux Archrolling release
Programming languageGov1.23.2
Linux shellFishv3.7.1

Dependencies

ProtoBuf compilerprotobufv28.2
ProtoBuf Go plugingoogle.golang.org/protobufv1.35.1
ProtoBuf gRPC Go plugingoogle.golang.org/grpcv1.68.0
Keccak256 hash, Argon2 KDFgolang.org/x/cryptov0.29.0
Secp256k1 elliptic curvegithub.com/dustinxie/ecclatest
CLI librarygithub.com/spf13/cobrav1.8.1

Installation

  • Install the Go programming language and the Fish Linux shell
yay -S go fish
  • Install the ProtoBuf compiler, the ProtoBuf Go plugin, and the ProtoBuf gRPC Go plugin
yay -S protobuf
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
  • Clone the Go blockchain repository, generate the gRPC client and server stubs, and build the blockchain executable bcn
git clone https://github.com/volodymyrprokopyuk/go-blockchain.git
cd go-blockchain
go get ./...
./grpc.fish
go build -o bcn
  • Set up the Fish completions for the blockchain executable bcn
cp bcn $GOPATH
./bcn completion fish > ~/.config/fish/completions/bcn.fish

Testing

  • Run the whole test suite storing the test coverage to a file
go test -v -cover -coverprofile=coverage.cov ./... -run .
  • Show the HTML test coverage report in a browser
go tool cover -html=coverage.cov

Directory structure

  • chain/ defines the core blockchain types
    • account.go defines the address and the account types
    • block.go defines the block and the signed block types
    • event.go defines the event type
    • genesis.go defines the genesis and the signed genesis types
    • merkle.go defines the Merkle hash, the Merkle prove, and the Merkle verify algorithms
    • state.go defines the state type
    • tx.go defines the hash, the transaction, and the signed transaction types
  • cli/ defines the CLI of the blockchain for clients
    • account.go defines the account create and the account balance commands
    • block.go defines the block search command
    • chain.go defines the main bcn command
    • node.go defines the node start and the node subscribe commands
    • tx.go defines the transaction sign, the transaction send, and the transaction search commands
  • doc/ defines the documentation of this blockchain
  • node/ defines the key components of the blockchain node
    • blockproposer.go defines the block proposer type
    • eventstream.go defines the event stream type
    • msgrelay.go defines the message relay generic type
    • node.go defines the node type
    • peerdiscovery.go defines the peer discovery type
    • statesync.go defines the state sync type
    • rpc/ defines and implements the gRPC services and methods
      • account.proto defines the gRPC account service and methods
      • accountsrv.go implements the gRPC account service
      • block.proto defines the gRPC block service and methods
      • blocksrv.go implements the gRPC block service
      • node.proto defines the gRPC node service and methods
      • nodesrv.go implements the gRPC node service
      • tx.proto defines the gRPC transaction service and methods
      • txsrv.go implements the gRPC transaction service
  • client.fish defines the txSignAndSend helper function for clients
  • grpc.fish compiles the definitions of the gRPC services and methods
  • main.go defines the main entry point to the bcn blockchain executable