cjdelisle/cjdns — pull request #642 by Arceliar (2014-08-25 22:41:11+00:00)
Title: Some janitor stuff

Mainly code cleanup, mainly in the janitor.

There were some spots of duplicate code that I didn't like the look of (namely to do with checking all the different RumorMills in the janitor), so I refactored the ugly part into a separate function.

Rewrote the keyspace maintainance part. Instead of having 2 nearly identical functions, it's now 2 different functions. One runs during the global cycle, and queues up a list of important addresses (selfNode address with 1 bit flipped) into yet another RumorMill, if the mill is empty. The other function runs during the local maint cycle, and just pops items form the mill to search for (or ping if a valid next hop already exists). Since the mill empties every 30 seconds on such a small network, this basically trades 2 searches (max length 8), for 1 search (max length 8) and around 9-10 pings, for a network our current size. Expect number of pings to increase logarithmically with network size, capping at most one per second. This makes sure that nodes which are important to keyspace are checked about once every 30 seconds (more like once/minute if the network ever becomes huge), as opposed to once every ~5 minutes before.