thaliproject / Thali_CordovaPlugin

Thali p2p plugin
MIT License
226 stars 44 forks source link

Add collision avoidance to thaliPeerPool #651

Open juhanak opened 8 years ago

juhanak commented 8 years ago

When a new peer appears and starts to advertise itself, there should be a random delay before clients try to connect to it in order to avoid collisions. Otherwise all clients try to connect to the same peer at the same time. This can be implemented in thaliPeerPool.

yaronyg commented 8 years ago

Actually this shouldn't be handled in thaliPeerPool because the peer pool doesn't really know anything about the semantics of an event. It would make more sense to put this into the notification code so that we essentially delay calling enqueue for a random period of time. Alternatively we could put a delay into the notification action itself so that it uses a time out before it makes a HTTP request.