本文整理汇总了Python中drogulus.dht.routingtable.RoutingTable.get_refresh_list方法的典型用法代码示例。如果您正苦于以下问题:Python RoutingTable.get_refresh_list方法的具体用法?Python RoutingTable.get_refresh_list怎么用?Python RoutingTable.get_refresh_list使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类drogulus.dht.routingtable.RoutingTable
的用法示例。
在下文中一共展示了RoutingTable.get_refresh_list方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_refresh_list
# 需要导入模块: from drogulus.dht.routingtable import RoutingTable [as 别名]
# 或者: from drogulus.dht.routingtable.RoutingTable import get_refresh_list [as 别名]
def test_get_refresh_list(self):
"""
Ensures that only keys from stale k-buckets are returned.
"""
parent_node_id = 'deadbeef'
r = RoutingTable(parent_node_id)
bucket1 = Bucket(1, 2)
# Set the lastAccessed flag on bucket 1 to be out of date
bucket1.last_accessed = time.time() - 3700
r._buckets[0] = bucket1
bucket2 = Bucket(2, 3)
bucket2.last_accessed = time.time()
r._buckets.append(bucket2)
expected = 1
result = r.get_refresh_list(0)
self.assertEqual(1, len(result))
self.assertEqual(expected, int(result[0], 0))
示例2: test_get_forced_refresh_list
# 需要导入模块: from drogulus.dht.routingtable import RoutingTable [as 别名]
# 或者: from drogulus.dht.routingtable.RoutingTable import get_refresh_list [as 别名]
def test_get_forced_refresh_list(self):
"""
Ensures that keys from all k-buckets (no matter if they're stale or
not) are returned.
"""
parent_node_id = 'deadbeef'
r = RoutingTable(parent_node_id)
bucket1 = Bucket(1, 2)
# Set the lastAccessed flag on bucket 1 to be out of date
bucket1.last_accessed = time.time() - 3700
r._buckets[0] = bucket1
bucket2 = Bucket(2, 3)
bucket2.last_accessed = time.time()
r._buckets.append(bucket2)
result = r.get_refresh_list(0, True)
# Even though bucket 2 is not stale it still has a key for it in
# the result.
self.assertEqual(2, len(result))
self.assertEqual(1, int(result[0], 0))
self.assertEqual(2, int(result[1], 0))