-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6627 from filecoin-project/feat/split-net-api
api: Separate the Net interface from Common
- Loading branch information
Showing
29 changed files
with
512 additions
and
489 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package api | ||
|
||
import ( | ||
"context" | ||
|
||
metrics "github.com/libp2p/go-libp2p-core/metrics" | ||
"github.com/libp2p/go-libp2p-core/network" | ||
"github.com/libp2p/go-libp2p-core/peer" | ||
"github.com/libp2p/go-libp2p-core/protocol" | ||
) | ||
|
||
// MODIFYING THE API INTERFACE | ||
// | ||
// When adding / changing methods in this file: | ||
// * Do the change here | ||
// * Adjust implementation in `node/impl/` | ||
// * Run `make gen` - this will: | ||
// * Generate proxy structs | ||
// * Generate mocks | ||
// * Generate markdown docs | ||
// * Generate openrpc blobs | ||
|
||
type Net interface { | ||
// MethodGroup: Net | ||
|
||
NetConnectedness(context.Context, peer.ID) (network.Connectedness, error) //perm:read | ||
NetPeers(context.Context) ([]peer.AddrInfo, error) //perm:read | ||
NetConnect(context.Context, peer.AddrInfo) error //perm:write | ||
NetAddrsListen(context.Context) (peer.AddrInfo, error) //perm:read | ||
NetDisconnect(context.Context, peer.ID) error //perm:write | ||
NetFindPeer(context.Context, peer.ID) (peer.AddrInfo, error) //perm:read | ||
NetPubsubScores(context.Context) ([]PubsubScore, error) //perm:read | ||
NetAutoNatStatus(context.Context) (NatInfo, error) //perm:read | ||
NetAgentVersion(ctx context.Context, p peer.ID) (string, error) //perm:read | ||
NetPeerInfo(context.Context, peer.ID) (*ExtendedPeerInfo, error) //perm:read | ||
|
||
// NetBandwidthStats returns statistics about the nodes total bandwidth | ||
// usage and current rate across all peers and protocols. | ||
NetBandwidthStats(ctx context.Context) (metrics.Stats, error) //perm:read | ||
|
||
// NetBandwidthStatsByPeer returns statistics about the nodes bandwidth | ||
// usage and current rate per peer | ||
NetBandwidthStatsByPeer(ctx context.Context) (map[string]metrics.Stats, error) //perm:read | ||
|
||
// NetBandwidthStatsByProtocol returns statistics about the nodes bandwidth | ||
// usage and current rate per protocol | ||
NetBandwidthStatsByProtocol(ctx context.Context) (map[protocol.ID]metrics.Stats, error) //perm:read | ||
|
||
// ConnectionGater API | ||
NetBlockAdd(ctx context.Context, acl NetBlockList) error //perm:admin | ||
NetBlockRemove(ctx context.Context, acl NetBlockList) error //perm:admin | ||
NetBlockList(ctx context.Context) (NetBlockList, error) //perm:read | ||
|
||
// ID returns peerID of libp2p node backing this API | ||
ID(context.Context) (peer.ID, error) //perm:read | ||
} | ||
|
||
type CommonNet interface { | ||
Common | ||
Net | ||
} | ||
|
||
type NatInfo struct { | ||
Reachability network.Reachability | ||
PublicAddr string | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.