subp2p Protocol
subp2p is a peer-to-peer (P2P) communication protocol that provides the foundation for VladSwap's decentralized order book. It is designed to be lightweight, secure, and censorship-resistant, enabling direct communication between users without relying on a centralized server.
Key Concepts
- WebTransport:
subp2pleverages the WebTransport API, a modern web technology that provides a low-latency, bidirectional, and secure communication channel between web browsers and servers. This allows for a P2P QUIC-compatible stack to run directly in the browser. - Subrelay: A
subrelayis a server that acts as a bridge between peers in thesubp2pnetwork. It helps to facilitate peer discovery and NAT traversal, but it does not have access to the content of the messages being exchanged. The primarysubrelayfor the VladSwap network is located atp2p.subfrost.io. - VladSwap Node: A
vladswap-nodeis a specializedsubrelaythat is specifically configured to participate in the VladSwap marketplace. These nodes are responsible for validating and propagating the PSBT order book, ensuring that all participants have a consistent and up-to-date view of the market.
Architecture
The subp2p network is a hybrid P2P architecture that combines the benefits of both pure P2P and client-server models.
- Peer Discovery: When a user connects to the VladSwap marketplace, their client communicates with a
subrelayto discover other peers on the network. - Direct Communication: Once peers have been discovered, they can establish a direct, end-to-end encrypted communication channel using WebTransport. This ensures that all messages are private and secure.
- Order Book Propagation: When a user creates a new order, the PSBT is broadcast to their connected peers. Each peer then validates the PSBT and, if it is valid, propagates it to their own peers. This process continues until the order has been disseminated throughout the entire network.
This architecture allows VladSwap to maintain a decentralized and resilient order book, without sacrificing performance or security.