-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Type updates #118
base: main
Are you sure you want to change the base?
Type updates #118
Conversation
type RecordProtocol[K Key[K], N NodeID[K]] interface { | ||
Get(ctx context.Context, to N, target K) ([]Record, []N, error) | ||
Put(ctx context.Context, to N, record Record) error | ||
CloserNodes() []N |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the part that seems like we would want to change back one day. A useful Kademlia library needs to support getting addresses for nodes in the network.
Here's an alternative.
Keep Request/Response, Address and NodeInfo.
Create a new type that just represents a set of nodes assumed to be close to a key:
type KeyNodes[K Key[K], N NodeID[K]] struct {
Key K
Nodes []N
}
Use this new type in all the routing and query state machines instead of Request
. Response
/Request
can still be used in endpoint and simplequery.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another idea: let's rename NodeID[K]
to Node[K]
and let the implementation of Node[K]
carry additional information. go-kademlia doesn't need to know anything about it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion from a private conversation.
Define
type Node[K kad.Key, P any] interface {
Key() K
Preimage() P
}
So a PeerNode
in libp2p is a Node[key.Key256, peer.ID]
It might even be better as a struct:
type Node[K kad.Key, P any] struct {
Key K
Preimage P
}
No description provided.