Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

coreapi swarm: unify impl type with other apis #5551

Merged
merged 1 commit into from
Oct 3, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion core/coreapi/coreapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,5 @@ func (api *CoreAPI) Dht() coreiface.DhtAPI {

// Swarm returns the SwarmAPI interface implementation backed by the go-ipfs node
func (api *CoreAPI) Swarm() coreiface.SwarmAPI {
return &SwarmAPI{api}
return (*SwarmAPI)(api)
}
11 changes: 5 additions & 6 deletions core/coreapi/swarm.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"sort"
"time"

core "github.com/ipfs/go-ipfs/core"
coreiface "github.com/ipfs/go-ipfs/core/coreapi/interface"

swarm "gx/ipfs/QmPQoCVRHaGD25VffyB7DFV5qP65hFSQJdSDy75P1vYBKe/go-libp2p-swarm"
Expand All @@ -17,12 +18,10 @@ import (
net "gx/ipfs/QmfDPh144WGBqRxZb1TGDHerbMnZATrHZggAPw7putNnBq/go-libp2p-net"
)

type SwarmAPI struct {
*CoreAPI
}
type SwarmAPI CoreAPI

type connInfo struct {
api *CoreAPI
node *core.IpfsNode
conn net.Conn
dir net.Direction

Expand Down Expand Up @@ -126,7 +125,7 @@ func (api *SwarmAPI) Peers(context.Context) ([]coreiface.ConnectionInfo, error)
addr := c.RemoteMultiaddr()

ci := &connInfo{
api: api.CoreAPI,
node: api.node,
conn: c,
dir: c.Stat().Direction,

Expand Down Expand Up @@ -161,7 +160,7 @@ func (ci *connInfo) Direction() net.Direction {
}

func (ci *connInfo) Latency() (time.Duration, error) {
return ci.api.node.Peerstore.LatencyEWMA(peer.ID(ci.ID())), nil
return ci.node.Peerstore.LatencyEWMA(peer.ID(ci.ID())), nil
}

func (ci *connInfo) Streams() ([]protocol.ID, error) {
Expand Down