Study Notes: Chapter 8 – Peer-to-Peer Network

1. Removing the Shared Folder

In earlier chapters, a shared folder acted as a central authority controlling block publication. This chapter replaces that folder with a fully decentralized peer-to-peer (P2P) network. Once the shared folder is gone, there’s no single point of authority to decide which blocks can be published, improving censorship resistance.

08 02
Figure 1. The shared folder administrator was a central authority (Luke). We remove that by building a decentralized P2P network.

2. The Peer-to-Peer Network

Q: How does a P2P network help remove the final central authority?

In a P2P network, all full nodes and miners connect directly with each other instead of relying on a single shared folder. This way, no single party can block or censor blocks/transactions because information can travel across alternate paths in the network.

08 03
Figure 2. A peer-to-peer “gossip” network: each node connects to multiple peers and forwards blocks/transactions to them.

3. Network Messages & Communication

Nodes communicate over TCP (Transmission Control Protocol) connections, speaking the “Bitcoin network protocol.” Key message types include:

08 09
Figure 3. Example inv message listing two transactions and one block ID.

Q: Why do nodes first send inv before tx (or block)?

Sending inv allows the receiving peer to decide if it wants the data (maybe it already has it). This saves bandwidth.

4. Following a Transaction Through the P2P Network

Let’s see how a single transaction propagates. Scenario: John buys a cookie from the cafe:

  1. Wallet → Node: John’s wallet is connected to Tom’s node. It sends an inv with the txid. Tom replies with getdata, and John’s wallet sends tx.
  2. Node → Node: Tom checks the transaction. If valid, he sends inv to his peers (Lisa, Qi, Rashid, cafe, etc.). Each peer that doesn’t have the transaction will getdata and receive tx.
  3. Notifying the recipient (the cafe): The cafe’s node sees the transaction matches its bloom filter, so it invs the cafe’s lightweight wallet. The cafe’s wallet getdata, and receives tx. The cafe sees a new pending transaction.
  4. Miner includes tx in a block: Suppose Rashid mines a block with John’s transaction. He sends headers first, peers reply with getdata, and he sends block. The block propagates network-wide.
  5. Wallets confirm: The cafe’s wallet (and John’s) receive a merkle proof (merkleblock) for that block, showing the transaction is included. They display “1 confirmation.”

5. Bootstrapping: Starting a New Full Node

A new full node needs to:

  1. Download and verify the Bitcoin Core software (or other node software).
  2. Open connections to peers via IP/port.
  3. Download and verify the entire blockchain (headers first, then blocks on the strongest chain).
  4. Enter normal operation (relay new blocks & transactions, etc.).
08 27
Figure 4. The steps for a new node: install, connect to peers, sync blocks, then join normal operation.

Q: Where does the node get peer addresses?

Possible sources:

Q: How does the node synchronize the chain?

  1. Download and verify all headers from the genesis block to the tip (getheaders / headers exchange).
  2. Identify the strongest chain (sum of difficulty in headers).
  3. Download full blocks (in parallel from multiple peers) with getdata / block exchanges.
  4. Verify each block’s transactions, build a UTXO set. Possibly skip signature checks before a certain known “checkpoint” block if you trust a known chain ID.

6. Key Takeaways


End of Study Notes for Chapter 8. The last piece of centralization (the shared folder) is gone, replaced by a robust P2P network ensuring true decentralization and censorship resistance.