Skip to content

Commit a121650

Browse files
author
postables
authored
Merge pull request #20 from RTradeLtd/fix/changes
Minor Merge Cleanup
2 parents 04b77b0 + a939820 commit a121650

File tree

345 files changed

+55786
-330
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

345 files changed

+55786
-330
lines changed

.travis.yml

Lines changed: 12 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,22 @@
1-
os:
2-
- linux
3-
41
language: go
5-
2+
sudo: required
63
go:
7-
- 1.11.x
8-
4+
- "1.12"
95
services:
10-
- docker
11-
12-
env:
13-
global:
14-
- GOTFLAGS="-race"
15-
- IPFS_PATH=/tmp/ipfs
16-
matrix:
17-
- BUILD_DEPTYPE=gx
18-
- BUILD_DEPTYPE=gomod
6+
- docker
7+
env: GO111MODULE=on
198

20-
before_install:
21-
- docker pull ipfs/go-ipfs:master
22-
- mkdir /tmp/ipfs && chmod 0777 /tmp/ipfs
23-
- docker run -d -v /tmp/ipfs:/data/ipfs -p 8080:8080 -p 4001:4001 -p 5001:5001 ipfs/go-ipfs:master --enable-pubsub-experiment
24-
25-
26-
# disable travis install
27-
install:
28-
- true
9+
before_script:
10+
- go vet ./...
11+
- go build ./...
12+
- go test -run xxxx ./...
13+
- make testenv
2914

3015
script:
31-
- go get -d -t github.com/cheekybits/is/... # remove with gx
32-
- bash <(curl -s https://raw.githubusercontent.com/ipfs/ci-helpers/master/travis-ci/run-standard-tests.sh)
33-
16+
- go test -race -failfast -coverprofile=coverage.txt ./...
3417

35-
cache:
36-
directories:
37-
- $GOPATH/src/gx
38-
- $GOPATH/pkg/mod
39-
- $HOME/.cache/go-build
18+
after_success:
19+
- bash <(curl -s https://codecov.io/bash)
4020

4121
notifications:
4222
email: false

Makefile

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
1-
all: deps
2-
gx:
3-
go get github.com/whyrusleeping/gx
4-
go get github.com/whyrusleeping/gx-go
5-
deps: gx
6-
gx --verbose install --global
7-
gx-go rewrite
8-
.PHONY: all gx deps
1+
GO=env GO111MODULE=on go
2+
GONOMOD=env GO111MODULE=off go
93

4+
.PHONY: deps
5+
deps:
6+
$(GO) mod vendor
7+
$(GO) mod verify
8+
109
# Set up test environment
1110
.PHONY: testenv
1211
WAIT=3
1312
testenv:
1413
@echo "=================== preparing test env ==================="
1514
( cd testenv ; make testenv )
1615
@echo "=================== done ==================="
16+
17+
.PHONY: clean
18+
clean:
19+
@echo "=================== stopping test env ==================="
20+
( cd testenv ; make clean )
21+
@echo "=================== done ==================="

go.mod

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
module github.com/ipfs/go-ipfs-api
22

33
require (
4+
github.com/RTradeLtd/go-ipfs-api v2.0.9+incompatible
45
github.com/cheekybits/is v0.0.0-20150225183255-68e9c0620927
56
github.com/ipfs/go-ipfs-files v0.0.1
6-
github.com/ipfs/go-ipfs-util v0.0.1
7+
github.com/ipfs/go-ipfs-util v0.0.1 // indirect
78
github.com/libp2p/go-libp2p-metrics v0.0.1
89
github.com/libp2p/go-libp2p-peer v0.0.1
910
github.com/mitchellh/go-homedir v1.1.0
1011
github.com/multiformats/go-multiaddr v0.0.1
1112
github.com/multiformats/go-multiaddr-net v0.0.1
13+
github.com/whyrusleeping/gx v0.14.2 // indirect
1214
github.com/whyrusleeping/tar-utils v0.0.0-20180509141711-8c6c8ba81d5c
1315
)

go.sum

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
github.com/RTradeLtd/go-ipfs-api v2.0.9+incompatible h1:LBG4bj/5X2YLXrKbADnCxfj1CDtN9hLsd22A68O9m7U=
2+
github.com/RTradeLtd/go-ipfs-api v2.0.9+incompatible/go.mod h1:gNXXZcJz7PkDXtUhjrlf4pSgDVV7yhVKQvLWUO/5k9o=
13
github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII=
24
github.com/btcsuite/btcd v0.0.0-20190213025234-306aecffea32 h1:qkOC5Gd33k54tobS36cXdAzJbeHaduLtnLQQwNoIi78=
35
github.com/btcsuite/btcd v0.0.0-20190213025234-306aecffea32/go.mod h1:DrZx5ec/dmnfpw9KyYoQyYo7d0KEvTkk/5M/vbZjAr8=
@@ -59,6 +61,7 @@ github.com/multiformats/go-multihash v0.0.1/go.mod h1:w/5tugSrLEbWqlcgJabL3oHFKT
5961
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
6062
github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
6163
github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
64+
github.com/whyrusleeping/gx v0.14.2/go.mod h1:e7k5R8Ndb9Ocdv8fWAeyg9uqjRuLl19xi/SvpGS0UuU=
6265
github.com/whyrusleeping/tar-utils v0.0.0-20180509141711-8c6c8ba81d5c h1:GGsyl0dZ2jJgVT+VvWBf/cNijrHRhkrTjkmp5wg7li0=
6366
github.com/whyrusleeping/tar-utils v0.0.0-20180509141711-8c6c8ba81d5c/go.mod h1:xxcJeBb7SIUl/Wzkz1eVKJE/CB34YNrqX2TQI6jY9zs=
6467
golang.org/x/crypto v0.0.0-20170930174604-9419663f5a44/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=

pubsub.go

Lines changed: 2 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
package shell
22

33
import (
4-
"encoding/binary"
54
"encoding/json"
65

7-
"github.com/libp2p/go-libp2p-peer"
8-
pb "github.com/libp2p/go-libp2p-pubsub/pb"
6+
peer "github.com/libp2p/go-libp2p-peer"
97
)
108

119
// Message is a pubsub message.
@@ -16,36 +14,6 @@ type Message struct {
1614
TopicIDs []string
1715
}
1816

19-
type message struct {
20-
*pb.Message
21-
}
22-
23-
func (m *message) GetFrom() peer.ID {
24-
return peer.ID(m.Message.GetFrom())
25-
}
26-
27-
type floodsubRecord struct {
28-
msg *message
29-
}
30-
31-
func (r floodsubRecord) From() peer.ID {
32-
return r.msg.GetFrom()
33-
}
34-
35-
func (r floodsubRecord) Data() []byte {
36-
return r.msg.GetData()
37-
}
38-
39-
func (r floodsubRecord) SeqNo() int64 {
40-
return int64(binary.BigEndian.Uint64(r.msg.GetSeqno()))
41-
}
42-
43-
func (r floodsubRecord) TopicIDs() []string {
44-
return r.msg.GetTopicIDs()
45-
}
46-
47-
///
48-
4917
// PubSubSubscription allow you to receive pubsub records that where published on the network.
5018
type PubSubSubscription struct {
5119
resp *Response
@@ -60,7 +28,7 @@ func newPubSubSubscription(resp *Response) *PubSubSubscription {
6028
}
6129

6230
// Next waits for the next record and returns that.
63-
func (s *PubSubSubscription) Next() (PubSubRecord, error) {
31+
func (s *PubSubSubscription) Next() (*Message, error) {
6432
if s.resp.Error != nil {
6533
return nil, s.resp.Error
6634
}

shell.go

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ func NewShell(url string) *Shell {
8282
func NewDirectShell(url string) *Shell {
8383
return &Shell{
8484
url: url,
85-
httpcli: &gohttp.Client{
85+
httpcli: gohttp.Client{
8686
Transport: &gohttp.Transport{
8787
Proxy: gohttp.ProxyFromEnvironment,
8888
DisableKeepAlives: true,
@@ -118,7 +118,7 @@ func NewShellWithClient(url string, c *gohttp.Client) *Shell {
118118
func (s *Shell) WithAuthorization(token string) *Shell {
119119
return &Shell{
120120
url: s.url,
121-
httpcli: &gohttp.Client{
121+
httpcli: gohttp.Client{
122122
Transport: newAuthenticatedTransport(s.httpcli.Transport, token),
123123
},
124124
}
@@ -160,18 +160,6 @@ func (s *Shell) ID(peer ...string) (*IdOutput, error) {
160160
return &out, nil
161161
}
162162

163-
// Cat the content at the given path. Callers need to drain and close the returned reader after usage.
164-
func (s *Shell) CatGet(path string) (io.ReadCloser, error) {
165-
resp, err := NewRequest(context.Background(), s.url, "cat", path).SendGET(s.httpcli)
166-
if err != nil {
167-
return nil, err
168-
}
169-
if resp.Error != nil {
170-
return nil, resp.Error
171-
}
172-
return resp.Output, nil
173-
}
174-
175163
// Cat the content at the given path. Callers need to drain and close the returned reader after usage.
176164
func (s *Shell) Cat(path string) (io.ReadCloser, error) {
177165
resp, err := s.Request("cat", path).Send(context.Background())

0 commit comments

Comments
 (0)