OpenBazaar/OpenBazaar — pull request #833 by Renelvon (2014-10-21 16:19:51+00:00)
Title: [WIP] Refactor routingtable and kbucket (part 2)

### Motivation
Further clean and test the `routingtable.py` module. Do some of the work outlined in #730.

### Changelog
* Delegate splitting to the `KBucket`. This allows better encapsulation, and, you guessed it, better tests.
* Create and test `MemKBucket` class, representing a `KBucket` with a replacement cache.
* Protect access to a `KBucket` via a recursive lock; it is now a thread-safe object.
* Drop `TreeRoutingTable` in favour of `OptimizedTreeRoutingTable`. The latter uses `MemKBucket`s and can cache contacts.
* Fix a bug in `findCloseNodes`.
* Push test coverage for `OptimizedRoutingTable` to 100%, by porting tests from the [drogulus](https://github.com/ntoll/drogulus/tree/master/tests) project.

### Note
* The diff is large, but more than half of it are tests. Don't be scared!
* I intend this to be in Beta 3.0, but I won't be working any more on that part of the system. Instead, I 'll try to see how we can replace our Kademlia implementation with `libtorrent`.