-
Notifications
You must be signed in to change notification settings - Fork 20.8k
p2p/discover: expose discv5 functions for portal JSON-RPC interface #31117
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
Conversation
Signed-off-by: Chen Kai <[email protected]>
p2p/discover/v5_udp.go
Outdated
// LocalNode returns the current local node running the | ||
// RoutingTableInfo returns the routing table information. Used for Portal discv5 RoutingTableInfo API. | ||
func (t *UDPv5) RoutingTableInfo() [][]string { | ||
return t.tab.nodeIds() |
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.
We should expose Table.Nodes
method instead because it has more information.
p2p/discover/v5_udp.go
Outdated
return t.tab.nodeIds() | ||
} | ||
|
||
// AddKnownNode adds a node to the routing table. Used for Portal discv5 AddEnr API. |
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 should have a comment that says it's only for testing.
p2p/discover/v5_udp.go
Outdated
|
||
// WaitInit waits for the routing table to be initialized. | ||
func (t *UDPv5) WaitInit() { | ||
t.tab.waitInit() |
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.
Better to add a config option (in discover/common.go
) that disables init check in table.
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 change will be made in another PR.
p2p/discover/v5_udp.go
Outdated
} | ||
|
||
// PingWithResp calls PING on a node and waits for a PONG response. | ||
func (t *UDPv5) PingWithResp(n *enode.Node) (*v5wire.Pong, error) { |
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.
We can just change Ping
signature to return the response object. No need to add WithoutResp
method.
Signed-off-by: Chen Kai <[email protected]>
Signed-off-by: Chen Kai <[email protected]>
Signed-off-by: Chen Kai <[email protected]>
…thereum#31117) Fixes ethereum#31093 Here we add some API functions on the UDPv5 object for the purpose of implementing the Portal Network JSON-RPC API in the shisui client. --------- Signed-off-by: Chen Kai <[email protected]>
This PR fix #31093 .
Function Renaming for Clarity:
discv5_ping
json rpc endpoint, added aPingWithResp
function and renamedPing
toPingWithoutResp
for refactoring.discv5_routingTableInfo
json rpc endpoint, addedRoutingTableInfo
function andnodeIds
function.discv5_deleteEnr
json rpc endpoint, addedDeleteNode
function anddeleteNode
function.discv5_lookupEnr
json rpc endpoint, addedResolveNodeId
function.discv5_addEnr
json rpc endpoint, addedAddKnownNode
function.discv5_GetEnr
json rpc endpoint, renamedgetNode
toGetNode
.discv5_findNode
json rpc endpoint, renamedfindnode
toFindnode
.WaitInit
function andwaitInit
for support portal hive test.AllNodes
function.This is the discv5 api impl code