CORE COURSE B
SOLVING DISTRIBUTED NETWORKING PROBLEMS WITH LIBP2P
Jacob Heun
@jacobheun
Cole Brown
@bigs
Alex Potsides
@achingbrain
GETTING THE STARTER CODE
Setup
WHAT IS LIBP2P?
WHAT ARE WE BUILDING?
Chat App
WHY A CHAT APP?
Connecting to Peers:
TRANSPORTS
19
PEERS
90
PEERS
93
PEERS
77
PEERS
33
PEERS
87
PEERS
17
PEERS
Transport | Browser | Node | Go | Rust |
TCP | | | | |
Websockets | | | | |
WebRTC | | | | |
QUIC | | | | |
SELECTING TRANSPORTS
Connecting to Peers:
CONFIGURING TRANSPORTS
< Configure the Transports >
01 Transports
02 Multiaddrs
03 Muxing & Encryption
04 Protocol
01
Connecting to Peers:
THE FIRST CONNECTION
Connecting to Peers:
MULTIADDRESS
(MULTIADDRS)
Connecting to Peers:
MULTIADDRS
Connecting to Peers:
MULTIADDRS
Connecting to Peers:
ADDING THE MULTIADDR
< Add the multiaddrs >
01 Transports
02 Multiaddrs
03 Muxing & Encryption
04 Protocol
02
REUSING CONNECTIONS
REUSING CONNECTIONS
REUSING CONNECTIONS
Reusing Connections
STREAM MULTIPLEXING (MUXING)
< Configure the Muxers >
04 Protocol
03 Muxing & Encryption
02 Multiaddrs
01 Transports
03
ENCRYPTING DATA
< Configure encryption >
01 Transports
02 Multiaddrs
03 Muxing & Encryption
04 Protocol
03
PROTOCOLS IN LIBP2P
Protocols
CREATING A PROTOCOL
< Create the Protocol >
04
05 Discovery
04 Protocol
03 Muxing & Encryption
02 Multiaddrs
5 minutes
TIME FOR BREAK!
Chatting with a Robot, how fun!
PEER DISCOVERY
Peer Discovery
DHT RANDOM WALK
Bob
Me
Alice
Brenda
Peer Discovery
MULTIPLE DISCOVERY SERVICES
< Configure discovery >
03 Muxing & Encryption
04 Protocol
05 Discovery
06 Pubsub
05
Recap
WELCOME BACK!
Pubsub
BROADCASTING MESSAGES
Pubsub
GOSSIPSUB OR FLOODSUB?
Transport | JS | Go | Rust |
Gossipsub | | | |
Floodsub | | | |
< Code chat over Pubsub >
04 Protocol
05 Discovery
06 Pubsub
07 Messaging
06
Protobuf
Complex Messaging
message Request {
enum Type {
SEND_MESSAGE = 0;
UPDATE_PEER = 1;
}
required Type type = 1;
optional SendMessage sendMessage = 2;
optional UpdatePeer updatePeer = 3;
}
message SendMessage {
required bytes data = 1;
required int64 created = 2;
required bytes id = 3;
}
message UpdatePeer {
optional bytes userHandle = 1;
}
< Complex Messaging >
07
07 Messaging
06 Pubsub
05 Discovery
04 Protocol
Subnets
How do we broadcast to a small set of peers in a network of millions?
ONE OF MANY
Subnets
BACK TO THE DHT
QmBob
QmMe
QmAlice
QmBrenda
Subnets
APPLYING THE DHT TO OUR CHAT
CLOSING THOUGHTS
The End!
https://github.com/js-libp2p-examples
JS EXAMPLE
discuss.libp2p.io
FORUM
https://github.com/go-libp2p-examples
GO EXAMPLE