6 Using Libp2p for content distribution

 

This chapter covers

  • Understanding peer-to-peer pub/sub systems
  • Using the publish and subscribe features of Libp2p to synchronize media

In this chapter, you’ll learn about the publish/subscribe (pub/sub) features of Libp2p. Using publish and subscribe, Web3 application developers allow instances of their application to send and receive messages to each other instead of communicating via a central server. This functionality replaces a central server and allows applications to stay up to date by synchronizing settings and code changes to deliver rich media and other content to users as they connect. To demonstrate this, you will update the Code Radio demo application to allow application instances to synchronize the music catalog to discover songs not in their local library and download those songs from peers. Within the Code Radio application architecture, Libp2p pub/sub communications are part of the base networking layer (figure 6.1).

Figure 6.1 Defining the Web3 application architecture of the Code Radio application starts at the base network layer.
figure ch06 01

6.1 Introduction to Pub/Sub messaging

6.2 Peer-to-peer pub/sub communication with Libp2p

6.2.1 Peering modes used by Libp2p

6.2.2 Libp2p pub/sub mechanics

6.2.3 How Libp2p handles pub/sub state

6.3 Enabling Libp2p pub/sub within Code Radio

6.4 Using pub/sub to serve music peer-to-peer

6.4.1 Defining Code Radio stations as subscriptions

6.4.2 Synchronizing music files using using message broadcasts

6.5 Summary