How Peers In Bitcoin Network Communicate?

In this lesson, we will read the next section of the Bitcoin whitepaper which explains how the Bitcoin peer-to-peer works.

In the last lesson we discussed how proof-of-work provides a solution to the problem of double spend by allowing us to figure out the next valid block to add to the chain.

In this lesson, we will learn about what the Bitcoin network is and the rules by which the nodes (i.e., computers) in the network communicate.

Recall that Bitcoin is a peer-to-peer network. Nodes in the network seek to achieve a common goal of maintaining the blockchain. The nodes must follow a protocol (i.e., rules) by which they communicate in order to maintain a valid chain of blocks.

Satoshi explains the steps that each node takes to run the network.

Let’s translate those steps into simpler terms, one at a time.

1) When a new transaction is created, it gets broadcast to the entire network.

2) Every node in the network is constantly listening for new transactions. Every time it hears a new transaction, it adds it into a block.

3) Each block can only store a certain number of transactions. Once a block has reached its limit, each node begins work on finding the required proof-of-work hash. (If you need a refresher on what a hash is, revisit the last lesson.)

4) As soon as a node finds a hash that meets the criteria for having a certain number of zero bits, it broadcasts the solution to all the blocks in the node.

5) If the hash and all the transactions in the block are valid, then all the other nodes accept this as the next block (recall that every node in the Bitcoin network stores the entire blockchain).

6) Recall that when solving for a proof-of-work hash, one of the inputs is the previous block’s hash. “Accept” the block means that nodes use the hash of this block as the previous hash.

And there you have it, folks. In a nutshell, that is how the Bitcoin network works. Of course, there are many nuances we skipped and unique cases to consider. For example, if two nodes publish a valid proof-of-work hash at the same time, how do nodes decide which one to accept? Well, a node will accept the block it heard first, but also save the other one just in case.

The node will keep working off of the block it heard first. If at a later point, the node realizes that the rest of the nodes in the network are extending another branch, then it will simply switch over to the longer branch.

This leaves us with a “stale block” that is no longer valid (and miners who mined that block do not receive rewards because it did not end up in the longest chain).

So at any point in time, there could be several branches of the blockchain that various nodes think is the canonical blockchain. This is why nodes typically wait for “six confirmations,” meaning, before they accept a transaction as valid, they wait until six more blocks have been confirmed on the chain in which the transaction was included.

Why six confirmations, specifically? As Satoshi proves mathematically at the end of the white paper, after six confirmations, the probability of a block being undone by a competing chain is low to the point of being negligible.

Another question you might have is…what happens to the stale blocks that don’t end up in the longest chain? Nothing. They are stale blocks, and the transactions in those blocks are not valid. If a transaction ends up in a stale block and was not included in the longest chain, then the client can rebroadcast the transaction so that it gets included into a block that makes it into the longest chain.

How about if a transaction gets broadcast but not all of the nodes hear it? As long as the transaction reaches many nodes, the transaction will get included into a block eventually.

And that’s a wrap for the Bitcoin network. Understanding how the network works can get confusing if you are new to distributed systems. Please don’t hesitate to reply with questions!

As you’ll recall, Bitcoin is built on a kind of reward system. Everyone likes rewards, and they serve as forms of motivation. So how does that work, exactly, in the Bitcoin context? In the next lesson, we will learn about how Bitcoin incentives. I will see you then.

About the author

Nicolas van Saberhagen

We created Cryptonote algorithm that has been used in creation of Monero.

Add Comment

Click here to post a comment

Learn Cryptocurrency!

Crypto secrets revealed about which no one is talking about.