Skip to content

Latest commit

 

History

History
46 lines (33 loc) · 5.01 KB

PIP-0005.md

File metadata and controls

46 lines (33 loc) · 5.01 KB

PIP-5: Add Peer

The flow of Add Peer is illustrated in the diagram.

Development Concerns

  1. My devices do not want to reveal my user-id directly to the neighbors, because it's possible that the neighbor is just some random peer.
  2. My devices intends to connect to only my friends' devices.

Implementation

  1. Initially in the Friend Service, when starting the PM of each friend, we try to connect to the friend-device (friend.PM.LoadPeers)
  2. When there is a connection established, we go through the IdentifyPeer process (service.PM.IdentifyPeer)
  3. When we know the user-id of the peer, we go through the FinishIdentifyPeer process (service.Ptt.FinishIdentifyPeer).
  4. We determine the peer-type of the peer, and register the peer to the corresponding Entities in the FinishIdentifyPeer process.

Steps

The steps is as follow:

  1. When starting the PM of each friend, we try to connect to the friend-device.
  2. When there is a connection established, we (the requester) think that the connected neighbor is our potential friend. We check with the potential-peer cache, and request identify-peer with the corresponding op-key.
  3. We (the receiver) receive identify-peer. If we can handle the request successfully, we issue the identify-peer-ack, and request identify-peer to the peer. Otherwise we issue identify-peer-fail to the peer.
  4. We (the requester) receive identify-peer-ack. If we can handle the ack successfully, we go through finish-identify-peer.
  5. We (the requester) receive identify-peer-fail. For now, we trust that the potential peer is our friend and we are willing to provide our identity. We issue identify-peer-with-myid to the peer.
  6. We (the receiver) receive identify-peer-with-myid. We would like to challenge that the peer really owns the user-id. We issue identify-peer-with-myid-challenge to the peer.
  7. We (the requester) receive identify-peer-with-myid-challenge. We sign the challenge and issue identify-peer-with-myid-challenge-ack to the peer.
  8. We (the receiver) receive identify-peer-with-myid-challenge-ack. If successfully process the ack, we issue identify-peer-with-myid-ack to the peer.
  9. We (the requester) receive identify-peer-with-myid-ack. If we successfully process the ack, we go through finish-identify-peer.

FinishIdentifyPeer

The flow of FinishIdentifyPeer is illustrated in the diagram. The steps is as follow:

  1. We determine the peer-type from all-entities.
  2. We validate (SetupPeer => addPeerKnownUserID) the peer with peer-type (not reaching max peers of the type).
  3. We set the peer-type.
  4. We register the peer to all the entities.
  5. We put the peer into the NewPeerCh channel, invoking Sync.