Code Monkey home page Code Monkey logo

the-blockchain-bar's Introduction

The Blockchain Bar

The source-code for: "Build a Blockchain from Scratch in Go" eBook.

๐Ÿ“š Get the eBook from: https://gumroad.com/l/build-a-blockchain-from-scratch-in-go

book cover

Table of Contents

TBB Training Ledger

Hi! ๐Ÿ‘‹

My name is Lukas. Nice to meet you, and welcome to the peer-to-peer world.

Is blockchain just an over-engineered database and a monetary mess? No. Every blockchain component and its architecture design decision has a technical reason enabling the decentralized, open, verifiable, transparent vision of Web3.

I am working in Web3 full-time since 2018. Do you know what was my biggest struggle? Understanding HOW blockchains work internally and WHY do we need components like Transaction, Block, Mempool, Consensus, Sync and Wallet in the first place. Reading low-level technical Yellow Papers is a noble, but honestly, a difficult starting point. The goal of this book is to introduce software developers to blockchain via a story - follow how a software developer, who is looking to revolutionize his local bar, implements blockchain technology for its payment system.

Enjoy the eBook.

What will you build?

Chapter by chapter, you will build a full peer-to-peer, autonomous training blockchain system in Go and learn all standard blockchain components!

1) You will build a peer-to-peer system from scratch

You start with 0 lines of code and end-up with 16 branches and a completely executable blockchain node.

PS: Don't worry if anything on the screen makes sense yet, it will once you go chapter by chapter; release by release.

peer-to-peer blockchain system in action

2) You will secure the system with a day-to-day practical cryptography

No boring theory. Only modern practices.

elliptic curve cryptography

3) You will implement Bitcoin, Ethereum and XRP backend components

From diagrams of mining algorithms to actual, implemented and working crypto wallets for storing the mined tokens and all other fundamental components that make blockchain special.

decentralized consensus

4) You will write unit tests and integration tests for all core components

You will test your cryptographic functions, a Bitcoin's like Proof of Work mining algorithm and other key components.

ethereum signature

How to use this repository

Every eBook chapter has a dedicated branch where you can experiment with the code first-hand.

git pull --all
git branch

> c1_genesis_json
> c2_db_changes_txt
> c3_state_blockchain_component
> c4_caesar_transfer
> c5_broken_trust
> c6_immutable_hash
> c7_blockchain_programming_model
> c8_transparent_db
> c9_tango
> c10_peer_sync
> c11_consensus
> c12_crypto
> c13_training_network
> c14_why_transaction_costs_gas
> c15_blockchain_forks_what_why_how
> c16_blockchain_explorer

Installation

Open full instructions.

Getting started

  1. Buy the eBook from: https://gumroad.com/l/build-a-blockchain-from-scratch-in-go
  2. Open the book at Chapter 1
  3. Checkout the first chapter's branch c1_genesis_json
git pull --all

git checkout c1_genesis_json

Usage

Install

go install ./cmd/...

Install with Docker

Open Docker instructions.

CLI

Show available commands and flags

tbb help

tbb run --help

Launches the TBB node and its HTTP API.

Usage:
  tbb run [flags]

Flags:
      --bootstrap-account string   default bootstrap Web3Coach's Genesis account with 1M TBB tokens (default "0x09ee50f2f37fcba1845de6fe5c762e83e65e755c")
      --bootstrap-ip string        default bootstrap Web3Coach's server to interconnect peers (default "node.tbb.web3.coach")
      --bootstrap-port uint        default bootstrap Web3Coach's server port to interconnect peers (default 443)
      --datadir string             Absolute path to your node's data dir where the DB will be/is stored
      --disable-ssl                should the HTTP API SSL certificate be disabled? (default false)
  -h, --help                       help for run
      --ip string                  your node's public IP to communication with other peers (default "127.0.0.1")
      --miner string               your node's miner account to receive the block rewards (default "0x0000000000000000000000000000000000000000")
      --port uint                  your node's public HTTP port for communication with other peers (configurable if SSL is disabled) (default 443)

Create a blockchain wallet account

tbb wallet new-account --datadir=$HOME/.tbb

> Please enter a password to encrypt the new wallet:
> Password:

Run a TBB node connected to the official book's test network

tbb version
> Version: 1.9.2-alpha  TX Gas

tbb run --datadir=$HOME/.tbb --ip=127.0.0.1 --port=8081 --miner=0x_YOUR_WALLET_ACCOUNT --disable-ssl

Your blockchain database will synchronize with rest of the students:

Launching TBB node and its HTTP API...
Listening on: 127.0.0.1:8081
Blockchain state:
- height: 0
- hash: 0000000000000000000000000000000000000000000000000000000000000000
Searching for new Peers and their Blocks and Peers: 'node.tbb.web3.coach:443'
Found 37 new blocks from Peer node.tbb.web3.coach:443
Importing blocks from Peer node.tbb.web3.coach:443...

Persisting new Block to disk:
{"hash":"000000a9d18730c133869d175a886d576df5675e0e73900bf072c59047b9d734","block":{"header":{"parent":"0000000000000000000000000000000000000000000000000000000000000000","number":0,"nonce":1925346453,"time":1590684713,"miner":"0x09ee50f2f37fcba1845de6fe5c762e83e65e755c"},"payload":[{"from":"0x09ee50f2f37fcba1845de6fe5c762e83e65e755c","to":"0x22ba1f80452e6220c7cc6ea2d1e3eeddac5f694a","value":5,"nonce":1,"data":"","time":1590684702,"signature":"0JE1yEoA3gwIiTj5ayanUZfo5ZnN7kHIRQPOw8/OZIRYWjbvbMA7vWdPgoqxnhFGiTH7FIbjCQJ25fQlvMvmPwA="}]}}

Persisting new Block to disk:
{"hash":"0000004d3faa1f7b8802aa809c8b77253859846602de3402a1bc67a0026cd94d","block":{"header":{"parent":"000000a9d18730c133869d175a886d576df5675e0e73900bf072c59047b9d734","number":1,"nonce":1331825342,"time":1592320406,"miner":"0x09ee50f2f37fcba1845de6fe5c762e83e65e755c"},"payload":[{"from":"0x09ee50f2f37fcba1845de6fe5c762e83e65e755c","to":"0x596b0709ed646e3e76b6c1fd58297b145b68387c","value":1000,"nonce":2,"data":"","time":1592320398,"signature":"1JIi9sYEZ+9RBG7IwACmm9vC4D7QVXqvBH1Es7cmeCJljTknVM80AzrhoLAW9RwCguunRO0qpN4JJ287VLFNfAE="}]}}
...

Or run a TBB bootstrap node in isolation (only on your machine)

tbb run --datadir=$HOME/.tbb_boostrap --ip=127.0.0.1 --port=8080 --bootstrap-ip=127.0.0.1 --bootstrap-port=8080 --disable-ssl

Test Network

You can also set up a server and be part of TBB blockchain network validating other student's transactions. Here is an example how the official TBB bootstrap node is launched. Customize the --datadir, --miner, and --ip values to match your server.

/usr/local/bin/tbb run --datadir=/home/ec2-user/.tbb --miner=0x09ee50f2f37fcba1845de6fe5c762e83e65e755c --ip=node.tbb.web3.coach --port=443 [email protected] --bootstrap-ip=node.tbb.web3.coach --bootstrap-port=443 --bootstrap-account=0x09ee50f2f37fcba1845de6fe5c762e83e65e755c

Tests

Run all tests with verbosity but one at a time, without timeout, to avoid ports collisions:

go test -v -p=1 -timeout=0 ./...

Run an individual test:

go test -timeout=0 ./node -test.v -test.run ^TestNode_Mining$

Note: Majority are integration tests and take time. Expect the test suite to finish in ~30 mins.

Start

Tutorial

๐Ÿ“š Get the eBook from: https://gumroad.com/l/build-a-blockchain-from-scratch-in-go

Finish

Request 1000 TBB testing tokens

Write a tweet and let me know how did you like this book! Tag me in it @Web3Coach and include your account address 0xYOUR_ADDRESS. I will send you 1000 testing TBB tokens.

See you on Twitter - @Web3Coach.

Or LinkedIn - LukasLukac


Disclaimer

The Blockchain Bar repository, the tbb binary and Build a Blockchain from Scratch in Go eBook is for learning, educational purposes. The codebase is NOT ready for production. The components are purposefully simplified to don't overwhelm new blockchain students, but complex enough to teach you how blockchains work under the hood.

License

The Blockchain Bar library (i.e. all code outside of the cmd directory) is licensed under the GNU Lesser General Public License v3.0, also included in our repository in the COPYING.LESSER file.

The Blockchain Bar binaries (i.e. all code inside of the cmd directory) is licensed under the GNU General Public License v3.0, also included in our repository in the COPYING file.

the-blockchain-bar's People

Contributors

cmaahs avatar deferbot avatar dnjp avatar splicemaahs avatar web3coach avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

the-blockchain-bar's Issues

the hash block is invalid

Searching for new Peers and their Blocks and Peers: 'node.tbb.web3.coach:443'
Found 3 new blocks from Peer node.tbb.web3.coach:443
Importing blocks from Peer node.tbb.web3.coach:443...
ERROR: invalid block hash 89bdfcde734cbab319bdc2d9e45bab3bcb5f899b28fb6fdf69613ba3d322229a
Searching for new Peers and their Blocks and Peers: 'node.tbb.web3.coach:443'
Found 3 new blocks from Peer node.tbb.web3.coach:443
Importing blocks from Peer node.tbb.web3.coach:443...
ERROR: invalid block hash 89bdfcde734cbab319bdc2d9e45bab3bcb5f899b28fb6fdf69613ba3d322229a
Searching for new Peers and their Blocks and Peers: 'node.tbb.web3.coach:443'
Found 3 new blocks from Peer node.tbb.web3.coach:443
Importing blocks from Peer node.tbb.web3.coach:443...
ERROR: invalid block hash 89bdfcde734cbab319bdc2d9e45bab3bcb5f899b28fb6fdf69613ba3d322229a

[no tests to run]

In branch c11_consensus, while running tests according to the book go test -timeout=0 -count=1 ./node -test.v -test.run ^TestNode_Run$, testing returns error:

testing: warning: no tests to run
PASS
ok      github.com/web3coach/the-blockchain-bar/node    0.003s [no tests to run]

I have installed tbb with usual go install ./cmd/..., it works.
How do I launch tests?

Blockchain

The Blockchain Bar

The source-code for: "Build a Blockchain from Scratch in Go" eBook.

๐Ÿ“š Get the eBook from: https://gumroad.com/l/build-a-blockchain-from-scratch-in-go

book cover

Table of Contents

TBB Training Ledger

Hi! ๐Ÿ‘‹

My name is Lukas. Nice to meet you, and welcome to the peer-to-peer world.

Is blockchain just an over-engineered database and a monetary mess? No. Every blockchain component and its architecture design decision has a technical reason enabling the decentralized, open, verifiable, transparent vision of Web3.

I am working in Web3 full-time since 2018. Do you know what was my biggest struggle? Understanding HOW blockchains work internally and WHY do we need components like Transaction, Block, Mempool, Consensus, Sync and Wallet in the first place. Reading low-level technical Yellow Papers is a noble, but honestly, a difficult starting point. The goal of this book is to introduce software developers to blockchain via a story - follow how a software developer, who is looking to revolutionize his local bar, implements blockchain technology for its payment system.

Enjoy the eBook.

What will you build?

Chapter by chapter, you will build a full peer-to-peer, autonomous training blockchain system in Go and learn all standard blockchain components!

1) You will build a peer-to-peer system from scratch

You start with 0 lines of code and end-up with 16 branches and a completely executable blockchain node.

PS: Don't worry if anything on the screen makes sense yet, it will once you go chapter by chapter; release by release.

peer-to-peer blockchain system in action

2) You will secure the system with a day-to-day practical cryptography

No boring theory. Only modern practices.

elliptic curve cryptography

3) You will implement Bitcoin, Ethereum and XRP backend components

From diagrams of mining algorithms to actual, implemented and working crypto wallets for storing the mined tokens and all other fundamental components that make blockchain special.

decentralized consensus

4) You will write unit tests and integration tests for all core components

You will test your cryptographic functions, a Bitcoin's like Proof of Work mining algorithm and other key components.

ethereum signature

How to use this repository

Every eBook chapter has a dedicated branch where you can experiment with the code first-hand.

git pull --all
git branch

> c1_genesis_json
> c2_db_changes_txt
> c3_state_blockchain_component
> c4_caesar_transfer
> c5_broken_trust
> c6_immutable_hash
> c7_blockchain_programming_model
> c8_transparent_db
> c9_tango
> c10_peer_sync
> c11_consensus
> c12_crypto
> c13_training_network
> c14_why_transaction_costs_gas
> c15_blockchain_forks_what_why_how
> c16_blockchain_explorer

Installation

Open full instructions.

Getting started

  1. Buy the eBook from: https://gumroad.com/l/build-a-blockchain-from-scratch-in-go
  2. Open the book at Chapter 1
  3. Checkout the first chapter's branch c1_genesis_json
git pull --all

git checkout c1_genesis_json

Usage

Install

go install ./cmd/...

Install with Docker

Open Docker instructions.

CLI

Show available commands and flags

tbb help

tbb run --help

Launches the TBB node and its HTTP API.

Usage:
  tbb run [flags]

Flags:
      --bootstrap-account string   default bootstrap Web3Coach's Genesis account with 1M TBB tokens (default "0x09ee50f2f37fcba1845de6fe5c762e83e65e755c")
      --bootstrap-ip string        default bootstrap Web3Coach's server to interconnect peers (default "node.tbb.web3.coach")
      --bootstrap-port uint        default bootstrap Web3Coach's server port to interconnect peers (default 443)
      --datadir string             Absolute path to your node's data dir where the DB will be/is stored
      --disable-ssl                should the HTTP API SSL certificate be disabled? (default false)
  -h, --help                       help for run
      --ip string                  your node's public IP to communication with other peers (default "127.0.0.1")
      --miner string               your node's miner account to receive the block rewards (default "0x0000000000000000000000000000000000000000")
      --port uint                  your node's public HTTP port for communication with other peers (configurable if SSL is disabled) (default 443)

Create a blockchain wallet account

tbb wallet new-account --datadir=$HOME/.tbb

> Please enter a password to encrypt the new wallet:
> Password:

Run a TBB node connected to the official book's test network

tbb version
> Version: 1.9.2-alpha  TX Gas

tbb run --datadir=$HOME/.tbb --ip=127.0.0.1 --port=8081 --miner=0x_YOUR_WALLET_ACCOUNT --disable-ssl

Your blockchain database will synchronize with rest of the students:

Launching TBB node and its HTTP API...
Listening on: 127.0.0.1:8081
Blockchain state:
- height: 0
- hash: 0000000000000000000000000000000000000000000000000000000000000000
Searching for new Peers and their Blocks and Peers: 'node.tbb.web3.coach:443'
Found 37 new blocks from Peer node.tbb.web3.coach:443
Importing blocks from Peer node.tbb.web3.coach:443...

Persisting new Block to disk:
{"hash":"000000a9d18730c133869d175a886d576df5675e0e73900bf072c59047b9d734","block":{"header":{"parent":"0000000000000000000000000000000000000000000000000000000000000000","number":0,"nonce":1925346453,"time":1590684713,"miner":"0x09ee50f2f37fcba1845de6fe5c762e83e65e755c"},"payload":[{"from":"0x09ee50f2f37fcba1845de6fe5c762e83e65e755c","to":"0x22ba1f80452e6220c7cc6ea2d1e3eeddac5f694a","value":5,"nonce":1,"data":"","time":1590684702,"signature":"0JE1yEoA3gwIiTj5ayanUZfo5ZnN7kHIRQPOw8/OZIRYWjbvbMA7vWdPgoqxnhFGiTH7FIbjCQJ25fQlvMvmPwA="}]}}

Persisting new Block to disk:
{"hash":"0000004d3faa1f7b8802aa809c8b77253859846602de3402a1bc67a0026cd94d","block":{"header":{"parent":"000000a9d18730c133869d175a886d576df5675e0e73900bf072c59047b9d734","number":1,"nonce":1331825342,"time":1592320406,"miner":"0x09ee50f2f37fcba1845de6fe5c762e83e65e755c"},"payload":[{"from":"0x09ee50f2f37fcba1845de6fe5c762e83e65e755c","to":"0x596b0709ed646e3e76b6c1fd58297b145b68387c","value":1000,"nonce":2,"data":"","time":1592320398,"signature":"1JIi9sYEZ+9RBG7IwACmm9vC4D7QVXqvBH1Es7cmeCJljTknVM80AzrhoLAW9RwCguunRO0qpN4JJ287VLFNfAE="}]}}
...

Or run a TBB bootstrap node in isolation (only on your machine)

tbb run --datadir=$HOME/.tbb_boostrap --ip=127.0.0.1 --port=8080 --bootstrap-ip=127.0.0.1 --bootstrap-port=8080 --disable-ssl

Test Network

You can also set up a server and be part of TBB blockchain network validating other student's transactions. Here is an example how the official TBB bootstrap node is launched. Customize the --datadir, --miner, and --ip values to match your server.

/usr/local/bin/tbb run --datadir=/home/ec2-user/.tbb --miner=0x09ee50f2f37fcba1845de6fe5c762e83e65e755c --ip=node.tbb.web3.coach --port=443 [email protected] --bootstrap-ip=node.tbb.web3.coach --bootstrap-port=443 --bootstrap-account=0x09ee50f2f37fcba1845de6fe5c762e83e65e755c

Tests

Run all tests with verbosity but one at a time, without timeout, to avoid ports collisions:

go test -v -p=1 -timeout=0 ./...

Run an individual test:

go test -timeout=0 ./node -test.v -test.run ^TestNode_Mining$

Note: Majority are integration tests and take time. Expect the test suite to finish in ~30 mins.

Start

Tutorial

๐Ÿ“š Get the eBook from: https://gumroad.com/l/build-a-blockchain-from-scratch-in-go

Finish

Request 1000 TBB testing tokens

Write a tweet and let me know how did you like this book! Tag me in it @Web3Coach and include your account address 0xYOUR_ADDRESS. I will send you 1000 testing TBB tokens.

See you on Twitter - @Web3Coach.

Or LinkedIn - LukasLukac


Disclaimer

The Blockchain Bar repository, the tbb binary and Build a Blockchain from Scratch in Go eBook is for learning, educational purposes. The codebase is NOT ready for production. The components are purposefully simplified to don't overwhelm new blockchain students, but complex enough to teach you how blockchains work under the hood.

License

The Blockchain Bar library (i.e. all code outside of the cmd directory) is licensed under the
GNU Lesser General Public License v3.0,
also included in our repository in the COPYING.LESSER file.

The Blockchain Bar binaries (i.e. all code inside of the cmd directory) is licensed under the
GNU General Public License v3.0, also
included in our repository in the COPYING file.

Before running TestNode_MiningSpamTransactions the base data needs to be reset

If the tests are run as a whole, and not individually, this test will fail because the accounts will have values from previous tests, rather than the initial setup values.

    node_integration_test.go:618: Andrej balance is incorrect. Expected: 0. Got: 250
    node_integration_test.go:622: BabaYaga balance is incorrect. Expected: 800. Got: 600
    node_integration_test.go:626: Miner balance is incorrect. Expected: 300. Got: 250
    node_integration_test.go:629: Andrej final balance: 250 TBB
    node_integration_test.go:630: BabaYaga final balance: 600 TBB
    node_integration_test.go:631: Miner final balance: 250 TBB
--- FAIL: TestNode_MiningSpamTransactions (480.01s)
FAIL
FAIL	github.com/web3coach/the-blockchain-bar/node	2262.935s
FAIL```

Go Modules & Book Review

Hi Lukas,

Just downloaded the book sample from your web3.coach website, and I will look into it.

As I wanted to ask you on LinkedIn (but aparently you need Premium license to send a message (or it's too late in the night for me right now ... ๐Ÿ˜ด), I am writing to you in this repo:

  1. Since Go 1.14 is already for available for some time, why not just start using it and Go modules, instead of keep promoting usage of the old GOPATH mode?
  2. About the book review, are you referring to what I just downloaded? Or the entire book you are planning to release in the near future? Either way, I would like to provide a review, if you are still interested.

Thanks.

Crypto Go ๏ผšwe are a research group to help developers build secure applications.

Hi, we are a research group to help developers build secure applications. We designed a cryptographic misuse detector (i.e., CryptoGo) on Go language. We found your great public repository from Github, and several security issues detected by CryptoGo are shown in the following.
Note that the cryptographic algorithms are categorized with two aspects: security strength and security vulnerability based on NIST Special Publication 800-57 and other public publications. Moreover, CryptoGo defined certain rules derived from the APIs of Go cryptographic library and other popular cryptographic misuse detectors. The specific security issues we found are as follows:
Location: node/sync.go:177;
Broken rule: HTTP is insecure;
We wish the above security issues could truly help you to build a secure application. If you have any concern or suggestion, please feel free to contact us, we are looking forward to your reply. Thanks.

Add output of state JSON

At the beginning you show the balances in a JSON file. So I added a simple additional command to do the same tbb balances state

var balancesStateCmd = &cobra.Command{
	Use:   "state",
	Short: "State of balances (json).",
	Run: func(cmd *cobra.Command, args []string) {
		state, err := dao.NewStateFromDisk()
		if err != nil {
			fmt.Fprintln(os.Stderr, err)
			os.Exit(1)
		}
		defer state.Close()

		json, err := json.MarshalIndent(state, "", "  ")
		if err != nil {
			fmt.Fprintln(os.Stderr, err)
			os.Exit(1)
		}
		fmt.Println(string(json))
	},

Section 3 doesn't have data attribute

It's a great tutorial - I haven't got to the end - but will raise any issues as I go along for you
It says CLI is done and includes this line

tbb tx add --from=andrej --to=andrej --value=100 --data=reward

but the -data flag isn't in the code at that stage so an error

Question about downloading

Hi, I'm interested in this tutorial, but I'm using Mac OS, not linux. Is there a download option for Mac OS?

When submitting an invalid transaction all nodes try to mine

Given:

  • Account with a certain balance
    When:
  • Transaction value is higher then value hold in balance for the account
    Then:
  • All nodes try to mine the block, the first successful can not add the block to the chain (as transaction is invalid), all the other nodes continue mining.

Maybe it would be good to have some pre-mining validation of each transaction?

Chapter 11 Branch's TestNode_Run fails with memory leak

Hi there, I am found a issue when following the book, and want to bring it to your attention here:

How it happened

As I got to the book's chapter 11, at page 301~304, there is this TestNode_Run test that is added, but locally, I could not make it pass.

I struggled with it for quite some time, because i was stubborn and tried to type the code all the way to here.....
So I went trough each of the files again and again trying to figure out what I was doing wrong that the test was failing..... And didn't get it

Finally I gave up and cloned the repo, went to branch c11_consensus and.... the test failed exactly as my local hand-typed version!

Checking out branch c12_crypto, and on, it Passes fine.

The error

Here is the error I get when run the
go test -timeout=0 -count=1 ./node -test.v -test.run ^TestNode_Run$ command:

--- FAIL: TestNode_Run (5.00s)
panic: runtime error: invalid memory address or nil pointer dereference [recovered]
        panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0x68f7ef]

Now What

Well, now I plan to check the diff between branches c11 and c12, hoping to figure out the problem before moving on to the next pages of the book.

When I checked out the c12_crypto branch, and ran the test, I saw that many dependencies were added, so I figure there are lots of logic and new things going on.

Because on the book the test passes at this point, I really want to understand what is wrong before going on the new content.

  • I created this issue because I know I will not have the will to do so after figuring out the problem....
  • But I really think it is important to mention it here, so hopefully the code or the book can be fixed.

Uncle Blocks?

Hi, Lukรกลก.

This is not an issue, but more like a feature request:

I was wondering if you had plans to integrate uncle blocks into the working of the application. Currently, I know we prevent any forks (ch_11), but I've read Ethereum incentivizes uncle blocks for a variety of reasons (at least in its PoW implementation). Would love to see it in action, and was wondering if you had any plans for it in future chapters.

Thanks!

PS: Excellent work, by the way. Absolutely love your book!

Error if no tx.db file

Basically the first state is a genesis file with no transactions, the transactions need adding. So no tx.db file if you use rm database/tx.db

I added this code:

// Now apply the transactions in the transaction file which is a set of json messages
txDbFilePath := filepath.Join(cwd, databaseDir, "tx.db")
// If the file doesn't exist then create it
_, err = os.Stat(txDbFilePath)
if os.IsNotExist(err) {
	_, err = os.Create(txDbFilePath)
}
if err != nil {
	return nil, err
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.