Re: #1232: Add a FindPeer RPC method

- Given a Peer ID, this method looks into the DHT to find that peer's addresses
- This commit also adds a CLI command to use this new RPC endpoint
This commit is contained in:
Aayush Rajasekaran
2020-02-18 16:31:42 -05:00
parent 6afeb2e72b
commit c742d45b19
5 changed files with 48 additions and 8 deletions
+6
View File
@@ -2,6 +2,7 @@ package impl
import (
"context"
"github.com/filecoin-project/lotus/node/modules/lp2p"
logging "github.com/ipfs/go-log/v2"
@@ -23,6 +24,7 @@ type CommonAPI struct {
APISecret *dtypes.APIAlg
Host host.Host
Router lp2p.BaseIpfsRouting
}
type jwtPayload struct {
@@ -81,6 +83,10 @@ func (a *CommonAPI) NetDisconnect(ctx context.Context, p peer.ID) error {
return a.Host.Network().ClosePeer(p)
}
func (a *CommonAPI) NetFindPeer(ctx context.Context, p peer.ID) (peer.AddrInfo, error) {
return a.Router.FindPeer(ctx, p)
}
func (a *CommonAPI) ID(context.Context) (peer.ID, error) {
return a.Host.ID(), nil
}