Skip to content

Endpoint::conn_type API improvements #3300

@flub

Description

@flub
Endpoint::conn_type(node_id: NodeId) -> anyhow::Result<Watcher<ConnectionType>>

This is a bad API:

  1. The Result is only error when the node_id does not exist. Normally rust uses an Option for this case though.
  2. Whether the endpoint knows about a NodeId or not is entirely out of control of the caller.
  3. The endpoint might forget a NodeId, if you have a life watcher at this time you would get ConnectionType::None and then the watcher would be pending until the endpoint knows about the NodeId again. Why does this behave differently then when calling it?

So potentially this should be infallible and return ConnectionType::None for unknown NodeIds?

Also, the name is terrible. #2806 (comment) suggests fn network_path(node_id: NodeId) -> Watcher<NetworkPath>.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    No status

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions