Actually, it's not too difficult. The hardest part is wrapping my head around the structure of the network. I've been able to create the binary tree structure of connections, and I've also been able to redirect a client that attempts to connect to a full node.
for example, say I have this tree and someone tries to connect to the root node ('-' is an empty connection).
a / \ | (these bars here are a work around for a forum bug) b c / \ / \ |- - d -
node A will halt the incoming connection and return a list of its children. By recursing on that list, the client can perform a depth-first search of the tree, until it reaches an empty spot. In this case, it will be the left node of b.
I need to do some major refactoring, but after that I think I will work on handling dropped connections (what happens to a branch when the parent of the branch leaves?) and then get some communication between the nodes (sharing of names, I think). That will all probably be about twice as much code as I have right now.
I'm thinking the best way to handle a dropped connection is wo use a leaf node to plug the gap. Take this tree:
a / \ | b c / \ / \ |d e f g
If node A drops the connection, this splits the b and c branches. Instead of promoting b or c and shuffling connections around to get everthing in place, I think the easiest answer is to select one of the leaf nodes to plug the whole.
d / \ | b c / \ / \ |- e f g
Each node will ideally maintain a complete image of the tree with IP numbers for each of the nodes, but only maintain connections with at most 3 other nodes. It will be a very high latency network (a message from node D to node G must first travel up the tree before then propogating down the tree), but it should be fairly robust if I can work out the dropped connection problem.
Eventually, the network should become a hydra beast of connection points. The idea is that an attempted connection on any one node of the network will eventually lead you to an open spot.
I'm somewhat worried about an ingrown tree, but my initial mullings on the subject indicate it's not possible.
a---b|\ /|| x ||/ \|c---d
a node is only allowed to specify its parent connection (or none, if one is not available). The only way this could happen is if a node can arbitrarily redefine its parent node. The only situation in which I can imagine wanting to allow this action is if I want two developed trees to be able to join each other.