Some net commands / apis
This commit is contained in:
+2
-3
@@ -2,7 +2,6 @@ package api
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/libp2p/go-libp2p-core/peer"
|
||||
)
|
||||
|
||||
@@ -34,9 +33,9 @@ type API interface {
|
||||
|
||||
// network
|
||||
|
||||
// // peers
|
||||
NetPeers(context.Context) ([]peer.AddrInfo, error) // TODO: check serialization
|
||||
NetConnect(context.Context, peer.AddrInfo) error
|
||||
// // ping
|
||||
// // connect
|
||||
|
||||
// Struct
|
||||
|
||||
|
||||
@@ -11,9 +11,20 @@ type Struct struct {
|
||||
Internal struct {
|
||||
ID func(context.Context) (peer.ID, error)
|
||||
Version func(context.Context) (Version, error)
|
||||
|
||||
NetPeers func(context.Context) ([]peer.AddrInfo, error)
|
||||
NetConnect func(context.Context, peer.AddrInfo) error
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Struct) NetPeers(ctx context.Context) ([]peer.AddrInfo, error) {
|
||||
return c.Internal.NetPeers(ctx)
|
||||
}
|
||||
|
||||
func (c *Struct) NetConnect(ctx context.Context, p peer.AddrInfo) error {
|
||||
return c.Internal.NetConnect(ctx, p)
|
||||
}
|
||||
|
||||
// ID implements API.ID
|
||||
func (c *Struct) ID(ctx context.Context) (peer.ID, error) {
|
||||
return c.Internal.ID(ctx)
|
||||
|
||||
Reference in New Issue
Block a user