Some net commands / apis

This commit is contained in:
Łukasz Magiera
2019-07-08 21:07:16 +02:00
parent 03227e1e27
commit cdca2ff2c7
9 changed files with 273 additions and 27 deletions
+2 -3
View File
@@ -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
View File
@@ -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)