Light client connection strategy
When talking about a light client, we must consider what services the light client wants to consume.
Specifically, we should probably talk about a light-client-for-data and light-client-for-pss etc.
Light client for data
What is a light client for data?
A client that wants to access data from Swarm (via retrieval requests) and pay for it accordingly.
It does not want to sync data, it does not want to serve retrieval requests to other nodes, nor participate in message routing in any way.
How should such a client connect to the swarm?
simplest: connect at random. or even simpler, connect to one node and use it as a gateway,
more structured: The client wants to get data as fast as possible. Thus it wants to spread its connections evenly throughout the address space.
For example, if a light client has the capacity to make 8 connections, then it is advisable to make one connection to a peer whose address begins with 000, one with 001, and so on up to 111.
In future further metrics for connection quality - bandwidth, latency, (price?) etc should come into play.
The clientâs own address does not play a role in the connection strategy.
Light Client for PSS
What is a light client for PSS?
A client that wants to be able to send and receive PSS messages, but does not want to take part in routing messages for other peers.
How should such a client connect to the swarm?
At the very least, such a client has to connect to the Swarm node whose address is closest to its own. Otherwise PSS messages addressed to the light client will not find it.
More practically it should attempt to connect to several closest nodes - similar in size to a most-proximate-neighbourhood for full nodes.
How should full nodes serve such light clients?
Most importantly, full nodes should not count connections to light clients as fulfilling any of its Kademlia or mostProximate connection obligations.
Beyond this syncing and message forwarding should be disabled for these connections.
For light data clients only incoming retrieval requests from the client (and uploads?) need to be responded to.
For light PSS clients, all messages addressed to the light client should be forwarded to the light client, and any PSS message originating from the light client should be forwarded in the Kademlia as if the full node itself had originated the message.