Log in using GitHub
Instacode
1
Remix
Code
Wallpaper
Source Code
Embed
def _kbucket_index(self, key): """ Returns the index of the k-bucket responsible for the specified key string. """ if isinstance(key, str): key = hex_to_long(key) # Bound check for key too small. if key < 0: raise ValueError('Key out of range') i = 0 for bucket in self._buckets: if bucket.key_in_range(key): return i else: i += 1 # Key was too big given the key space. raise ValueError('Key out of range.')
Anonymous
Jan. 29, 2013, 9:30 a.m.
Stand by