Skip to content
This repository has been archived by the owner on Mar 11, 2020. It is now read-only.

Streaming interface #28

Closed
dirkmc opened this issue Apr 22, 2019 · 4 comments
Closed

Streaming interface #28

dirkmc opened this issue Apr 22, 2019 · 4 comments

Comments

@dirkmc
Copy link

dirkmc commented Apr 22, 2019

Currently the Connection interface has the following fields and methods:

  • getObservedAddrs(callback)
  • getPeerInfo(callback)
  • setPeerInfo(peerInfo)
  • source
  • sink

Which of these are required for the streaming (async/await) interface?

@dirkmc
Copy link
Author

dirkmc commented Apr 22, 2019

@vasco-santos
Copy link
Member

Moving to use async iterators, I am thinking about the following:

getObservedAddrs(): Promise<Multiaddr[]>
getPeerInfo(): PeerInfo

source() => Iterable
sink() => function

close() => Promise

I don't remember why we have setPeerInfo. Any idea @jacobheun ?

I am working on a PR for this today

@jacobheun
Copy link
Contributor

I don't remember why we have setPeerInfo.

Right now, a Connection can actually be a wrapping of many Connection instances, represented as the not very well named info property. setPeerInfo ensures that the peerInfo is set recursively on all Connection instances. It is typically called after crypto has identified and verified the peer.

getPeerInfo() will need to be async. It's overridden when libp2p-identify is on and involves async actions. There may be better ways to do this, but without significant refactoring, it will need to stay the same.

close() => Promise

adding a close method on connections would be very useful for users as a convenience method.

@jacobheun
Copy link
Contributor

The new api has been released, closing this.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants