-
Notifications
You must be signed in to change notification settings - Fork 64
Discussion: when to send _ring and when to send _line?
Jer told me:
the _line and _ring values when wrong should drop the entire telex
Right, only it turns out not to be so easy to implement. The first implementation of clj-telehash got it right when talking to telehash:42424 (Jer’s perl implementation) when to send _ring and when to send _line. Now however I’m playing out two clj-telehash switches against each other and two things happen depending on how I tweak the implementation:
- Either the incoming telexes are dropped because the ring/line value received is not as expected.
- Or the _line is never sent because each instance waits until the other sends a _line, but since both instances run the same code the code basically waits for itself to do something it’s been programmed not to do.
So, literally, I’m in a deadlock. The only solution I can think of at this point is to add a hash of “ipA:portA-sent-ring-to-ipB:portB” to the DHT. The other instance can then look for this hash and hence “handshake the handshake”. Or, am I missing something?
Anyway, I’ve been tweaking enough at this point to realize I’m going nowhere fast. At first I didn’t even understand why telexes were being dropped. I would like to come up with an algorithm here that all switch implementations can implement.
The solution is very simple: each switch should send out a _ring with the first telex to another switch. That switch can then respond with _line. clj-telehash wasn’t doing this.
_line is always the product of two _ring values that can be extrapolated when one _ring value and the _line value is known:
_ring1 = _line / _ring2
_ring2 = _line / _ring1
_line mod _ring1 = _line mod _ring2 = 0