Last night I couldn't sleep, so I got up and worked on ebt for a bit. I just tidied stuff up, moved stuff that was performed frequently into a function. This made the code shorter, and easier to read, and removed a couple of inconsistencies.
I also realized a problem: for each feed. there are several things you want to communicate: the sequence, wether you want to be in receive mode. the sequence is a number, but receive mode is 1 bit. There is also wether you choose not to replicate this feed (because you don't know who that is). If you send unreplicate
you don't have anything to say about the others.
Currently these are all encoded as a single number: if it's positive or zero, it's rx+seq, if it's -1 it's unreplicate. if it's -2 or lower it's !rx+~seq. note: ~ is a bitwise op that turns 1 to zero, and -2 to 1.
But the problem, is that there is no way to encode seq 0 + !rx. This is needed so you can ask for a new feed just one peer, but have other peers tell if they have something new. without that, it's necessary request them all in receive mode, which may mean they send you the same stuff for a while until you can get another message back to them.
Changing this will mean that peers running ebt@<5 won't be compatible with 5. I think that is okay though, since this hasn't been widely deployed yet.
Making upgrades in distributed systems is hard and we must embrace this! If we don't, and this protocol is successful, we'll end up with various legacy layers that made sense at the time (when we didn't understand the problem) and future generations will just have to accept that. I don't want to trap future generations in my innocent mistakes, I want them to be able to build past my bad ideas and keep my good ones if they still seem good.