Skip to main content

How It Works

The subp2p protocol is designed to be simple and efficient, enabling low-latency communication between peers in the VladSwap network. Here's a step-by-step breakdown of how it works:

1. Peer Discovery

When a user first connects to the VladSwap marketplace, their client needs to discover other peers to connect to. This is accomplished by contacting a subrelay server, such as the one located at p2p.subfrost.io.

The client sends a request to the subrelay, which then returns a list of other active peers on the network. This list includes the necessary information for the client to establish a direct connection with each peer.

2. Direct Communication via WebTransport

Once the client has a list of peers, it can establish a direct, end-to-end encrypted communication channel with each of them using the WebTransport API. This is a modern web technology that provides a number of advantages over traditional WebSockets, including:

  • Low Latency: WebTransport is built on top of the QUIC protocol, which is designed for low-latency communication.
  • Bidirectional Communication: Both the client and the peer can send and receive data at any time, without having to wait for a response.
  • Secure: All communication is encrypted using TLS, ensuring that all data is private and secure.

3. Order Book Propagation

Once a direct connection has been established, the peers can begin to exchange information about the order book. When a user creates a new order, the PSBT is broadcast to all of their connected peers.

Each peer that receives the PSBT then validates it to ensure that it is well-formed and that the user has sufficient funds to complete the trade. If the PSBT is valid, the peer then propagates it to all of their own connected peers.

This process continues until the order has been disseminated throughout the entire network, ensuring that all participants have a consistent and up-to-date view of the market.

4. Community-Run Relays

While the primary subrelay at p2p.subfrost.io is maintained by the VladSwap team, the network is designed to be decentralized and resilient. Anyone can run their own vladswap-node to help maintain the network's order book.

By running a vladswap-node, you can help to improve the performance and reliability of the network, while also earning a portion of the trading fees.