lotus/api/struct.go

39 lines
907 B
Go
Raw Normal View History

package api
import (
"context"
"github.com/libp2p/go-libp2p-core/peer"
)
2019-07-02 13:05:43 +00:00
// Struct implements API passing calls to user-provided function values.
type Struct struct {
Internal struct {
ID func(context.Context) (peer.ID, error)
Version func(context.Context) (Version, error)
2019-07-08 19:07:16 +00:00
NetPeers func(context.Context) ([]peer.AddrInfo, error)
NetConnect func(context.Context, peer.AddrInfo) error
}
}
2019-07-08 19:07:16 +00:00
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)
}
2019-07-02 13:05:43 +00:00
// ID implements API.ID
func (c *Struct) ID(ctx context.Context) (peer.ID, error) {
return c.Internal.ID(ctx)
}
2019-07-02 13:05:43 +00:00
// Version implements API.Version
func (c *Struct) Version(ctx context.Context) (Version, error) {
return c.Internal.Version(ctx)
}
var _ API = &Struct{}