如何在 kademlia 中找到给定键的值?
Kademlia 有 4 条 RPC 消息:
ping
store
find_node
find_value
Kademlia 节点如何查找给定键的值?给定一个 id,很明显,对于 $n$
大小的网络中的节点来说,只需 $log(n)$
步骤即可找到具有该 id 的节点ID。但是一个节点如何有效地找到另一个存储了给定键值对的节点呢?如果人们对持有该键的节点一无所知,则必须采用 $n$
节点的顺序才能检索键的值。
Kademlia has 4 RPC messages:
ping
store
find_node
find_value
How does a Kademlia node find the value for a given key? Given an id, it is clear that it will take only $log(n)$
steps for a node in a network of size $n$
to find the node with that id. But how can a node efficiently find another node that has stored a given key-value pair? It would have to be of the order of $n$
nodes to retrieve the value for a key if one knew nothing about the node holds it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Kademlia 是一种 DHT,一种分布式哈希表。检索在概念上类似于常规内存中哈希表。您首先对密钥进行散列,以找到表中您可以对 ID 进行细化的位置,然后查看该位置。在 kademlia 中,这意味着您对 ID 进行有针对性的查找,等于密钥的哈希值。
Kademlia is a DHT, a distributed hash table. Retrieval is conceptually similar to a regular in-memory hash table. You first hash the key to find the place where in the table you would fine the ID and then you look at that location. In kademlia this means you do a targeted lookup towards the ID equals the hash of the key.
在 Kademlia 中,每个节点都包含一个形式的哈希表。其中与每个值关联的键是节点的 ID。这个<键,值>然后将条目存储在距离该键最近的 k 个节点中。 find_value RPC 的工作方式与 find_node 类似。首先查询您知道的与该键最接近的 k 个节点,它们返回与该键关联的值(如果有的话)或与该键最接近的 k 个节点。
In Kademlia, each node contains a hash table of the form <key,value> where the key associated with each value is a node's ID. This <key,value> entry is then stored in the k-closest nodes to the key. The find_value RPC works similarly to a find_node. First query the k-closest nodes you know to that key, they return the value associated with the key (if they have it) or their k-closest nodes to the key.