Skip to content
Sara Tavares edited this page Nov 17, 2022 · 1 revision

Blink is in charge of handling all data sent over P2P within Warp.

Core

Blink::pair(peers: Vec<DIDKey>) - connect to another blink peer

the vec of DID keys all contain the public keys we want to connect to, we can connect to one or more people this way by passing more or less DIDKeys

This should connect to another peer, or group of peers, given a vec of DIDKey’s

Once Paired it should start caching all signed and trusted Sata formatted data.

Blink::open(peers: Vec<DIDKey>) - open paired peer’s communication channel and listen for data.

  • should be able to connect to one or more at a time
  • start the communication of data.
  • called after pairing automatically, usually.

verify the data then pass it to the cache method.

Blink::cache - interface with cacher to store incoming Sata only from paired peers.

The internal method is used to cache a piece of data in Sata format.

Blink::hook - listen for specific events coming from other peers

  • Subscribe to new messages from peers.
  • Allow filtering by list of recipients
  • Do NOT block caching

Blink::send_direct - send data (Sata) to a paired peer

Sends data to a specific peer.

Blink::send - automatically sends Sata to the list of DIDKey recipients if we are paired

using the send_direct method under the hood.

may also try to send data to peers we’re not connected to, we should ignore those instances.

Blink::stream - open a stream of data between another peer should return a stream struct with options to change to video, screen share, etc provided.

Blink::call - alias to stream with the “call” enum passed

Blink::video - alias to stream with “video” enum passed

Blink::share_screen - alias to stream with the “screen_share” enum passed

Stream Broker

StreamBroker::get - returns a stream given a CID as a reference

StreamBroker::set - creates a reference to a stream and returns it as a Sata object

trait Blink {
  // Handshakes to another peer and verifies identity
  pair(peers: Vec<DIDKey>) -> Result<Ok, Err>
  // Starts listening for data from the remote peer(s)
  open(peers: Vec<DIDKey>) -> Result<Ok, Err>
  // Caches data to pocket dimension
  cache(data: Sata) -> Result<Ok, Err>
  // Allows developers to listen in on communications and hook data they care about
  hook(event: Blink::Events)
  // Send data directly to another peer(s)
  send(peers:Vec<DIDKey>, data: Sata) -> Result<Ok, Err>
  // Stream data to another peer(s)
  stream(peers:Vec<DIDKey>, kind: StreamKind, stream: Stream) -> Result<Ok, Err>


  // aliases
  call(peers: Vec<DIDKey>, stream: Stream) -> Result<Ok, Err> // calls stream()
  video(peers: Vec<DIDKey>, stream: Stream) -> Result<Ok, Err> // calls stream()
  screen_share(peers: Vec<DIDKey>, stream: Stream) -> Result<Ok, Err> // calls stream()
}
Clone this wiki locally