当前位置: 首页>>代码示例>>Python>>正文


Python RoutingTable._bucket_index方法代码示例

本文整理汇总了Python中drogulus.dht.routingtable.RoutingTable._bucket_index方法的典型用法代码示例。如果您正苦于以下问题:Python RoutingTable._bucket_index方法的具体用法?Python RoutingTable._bucket_index怎么用?Python RoutingTable._bucket_index使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在drogulus.dht.routingtable.RoutingTable的用法示例。


在下文中一共展示了RoutingTable._bucket_index方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_bucket_index_multiple_buckets

# 需要导入模块: from drogulus.dht.routingtable import RoutingTable [as 别名]
# 或者: from drogulus.dht.routingtable.RoutingTable import _bucket_index [as 别名]
 def test_bucket_index_multiple_buckets(self):
     """
     Ensures the expected index is returned when multiple buckets exist.
     """
     parent_node_id = 'deadbeef'
     r = RoutingTable(parent_node_id)
     r._split_bucket(0)
     split_point = int((2 ** 512) / 2)
     lower_key = hex(split_point - 1)[2:]
     higher_key = hex(split_point + 1)[2:]
     expected_lower_index = 0
     expected_higher_index = 1
     actual_lower_index = r._bucket_index(lower_key)
     actual_higher_index = r._bucket_index(higher_key)
     self.assertEqual(expected_lower_index, actual_lower_index)
     self.assertEqual(expected_higher_index, actual_higher_index)
开发者ID:No9,项目名称:drogulus,代码行数:18,代码来源:test_routingtable.py

示例2: test_bucket_index_as_string_and_int

# 需要导入模块: from drogulus.dht.routingtable import RoutingTable [as 别名]
# 或者: from drogulus.dht.routingtable.RoutingTable import _bucket_index [as 别名]
 def test_bucket_index_as_string_and_int(self):
     """
     Ensures that the specified key can be expressed as both a string
     and integer value.
     """
     parent_node_id = 'deadbeef'
     r = RoutingTable(parent_node_id)
     # key as a string
     test_key = 'abc123'
     expected_index = 0
     actual_index = r._bucket_index(test_key)
     self.assertEqual(expected_index, actual_index)
     # key as an integer
     test_key = '1234567'
     actual_index = r._bucket_index(test_key)
     self.assertEqual(expected_index, actual_index)
开发者ID:No9,项目名称:drogulus,代码行数:18,代码来源:test_routingtable.py

示例3: test_bucket_index_single_bucket

# 需要导入模块: from drogulus.dht.routingtable import RoutingTable [as 别名]
# 或者: from drogulus.dht.routingtable.RoutingTable import _bucket_index [as 别名]
 def test_bucket_index_single_bucket(self):
     """
     Ensures the expected index is returned when only a single bucket
     exists.
     """
     parent_node_id = 'deadbeef'
     r = RoutingTable(parent_node_id)
     # a simple test with only one bucket in the routing table.
     test_key = 'abc123'
     expected_index = 0
     actual_index = r._bucket_index(test_key)
     self.assertEqual(expected_index, actual_index)
开发者ID:No9,项目名称:drogulus,代码行数:14,代码来源:test_routingtable.py


注:本文中的drogulus.dht.routingtable.RoutingTable._bucket_index方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。