x/ref: Implement ListenForPeers
This CL does the following things.
1. modify the underlying queue implementation
- It now handles both Peer and Invite through the copyable interface.
- copyable introduces the concept of a "lost" invite or peer.
- When the copyable is removed from the queue, a "lost" version is
inserted in its stead.
- "lost" elements are only visible to cursors that have seen the
corresponding found elements.
- "lost" elements remain within the queue, and thus affect its "size".
- Garbage collection of the "lost" elements occurs once everybody
qualified to see the element has seen it via "next" OR has canceled
and unregistered themselves from the queue.
- Tests adjusted to take into account "lost" updates.
New tests added to take into account "lost" update garbage collection.
2. ListenForPeers is updated.
- Tests remain the same; it ignores the "lost" Invites.
3. ListenForInvites was added.
- Tests added by mocking out discovery.
3 files changed