Skip to content

Commit

Permalink
Merge pull request #20 from TRON-US/ipfs-0.5.1
Browse files Browse the repository at this point in the history
Upgrade to upstream IPFS 0.5.1 module
  • Loading branch information
steveyeom authored May 16, 2020
2 parents 1e8a724 + e918033 commit 1918b36
Show file tree
Hide file tree
Showing 16 changed files with 442 additions and 207 deletions.
21 changes: 16 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,32 @@ os:
language: go

go:
- 1.11.x
- 1.13.x

services:
- docker

env:
global:
- GO111MODULE=on
- GOTFLAGS="-race"
- IPFS_PATH=/tmp/ipfs
matrix:
- BUILD_DEPTYPE=gx
- BUILD_DEPTYPE=gomod


# disable travis install
before_install:
- docker pull ipfs/go-ipfs:master
- mkdir /tmp/ipfs && chmod 0777 /tmp/ipfs
- docker run -d -v /tmp/ipfs:/data/ipfs -p 8080:8080 -p 4001:4001 -p 5001:5001 ipfs/go-ipfs:master "daemon" "--enable-namesys-pubsub"

install:
- true
- go mod download

before_script:
- go vet ./...

script:
- go get -d github.com/cheekybits/is/... # remove with gx
- bash <(curl -s https://raw.githubusercontent.com/ipfs/ci-helpers/master/travis-ci/run-standard-tests.sh)


Expand Down
8 changes: 0 additions & 8 deletions Makefile

This file was deleted.

11 changes: 5 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
# go-btfs-api

> An unofficial go interface to btfs's HTTP API
> Go interface to BTFS HTTP API
## Install

```sh
go get -u github.com/ipfs/go-btfs-api
go get -u github.com/TRON-US/go-btfs-api
```

This will download the source into `$GOPATH/src/github.com/TRON-US/go-btfs-api`.

## Usage

See [the godocs](https://godoc.org/github.com/TRON-US/go-btfs-api) for details on available methods. This should match
the
See [the godocs](https://pkg.go.dev/github.com/TRON-US/go-btfs-api) for details on available methods.

### Example

Expand Down Expand Up @@ -42,12 +41,12 @@ func main() {
}
```

For a more complete example, please see: https://github.com/ipfs/go-btfs-api/blob/master/tests/main.go
For a more complete example, please see: https://github.com/TRON-US/go-btfs-api/blob/master/tests/main.go

## Contribute

Contributions are welcome! Please check out the [issues](https://github.com/btfs/go-btfs-api/issues).

## License

MIT
MIT @ TRON-US.
26 changes: 21 additions & 5 deletions add.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import (
"errors"
"io"
"os"
"path"
"path/filepath"

"github.com/TRON-US/go-btfs-files"
files "github.com/TRON-US/go-btfs-files"
)

type object struct {
Expand Down Expand Up @@ -59,6 +59,22 @@ func RawLeaves(enabled bool) AddOpts {
}
}

// Hash allows for selecting the multihash type
func Hash(hash string) AddOpts {
return func(rb *RequestBuilder) error {
rb.Option("hash", hash)
return nil
}
}

// CidVersion allows for selecting the CID version that btfs should use.
func CidVersion(version int) AddOpts {
return func(rb *RequestBuilder) error {
rb.Option("cid-version", version)
return nil
}
}

func (s *Shell) Add(r io.Reader, options ...AddOpts) (string, error) {
fr := files.NewReaderFile(r)
slf := files.NewSliceDirectory([]files.DirEntry{files.FileEntry("", fr)})
Expand All @@ -72,13 +88,13 @@ func (s *Shell) Add(r io.Reader, options ...AddOpts) (string, error) {
return out.Hash, rb.Body(fileReader).Exec(context.Background(), &out)
}

// AddNoPin adds a file to ipfs without pinning it
// AddNoPin adds a file to btfs without pinning it
// Deprecated: Use Add() with option functions instead
func (s *Shell) AddNoPin(r io.Reader) (string, error) {
return s.Add(r, Pin(false))
}

// AddWithOpts adds a file to ipfs with some additional options
// AddWithOpts adds a file to btfs with some additional options
// Deprecated: Use Add() with option functions instead
func (s *Shell) AddWithOpts(r io.Reader, pin bool, rawLeaves bool) (string, error) {
return s.Add(r, Pin(pin), RawLeaves(rawLeaves))
Expand Down Expand Up @@ -108,7 +124,7 @@ func (s *Shell) AddSerialFileDir(dir string, reedSolomon bool) (string, error) {
if err != nil {
return "", err
}
slf := files.NewSliceDirectory([]files.DirEntry{files.FileEntry(path.Base(dir), sf)})
slf := files.NewSliceDirectory([]files.DirEntry{files.FileEntry(filepath.Base(dir), sf)})
reader := files.NewMultiFileReader(slf, true)

return s.addDirectoryFromReader(reader, reedSolomon)
Expand Down
3 changes: 2 additions & 1 deletion dag.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"strings"

"github.com/TRON-US/go-btfs-api/options"
"github.com/TRON-US/go-btfs-files"
files "github.com/TRON-US/go-btfs-files"
)

func (s *Shell) DagGet(ref string, out interface{}) error {
Expand Down Expand Up @@ -52,6 +52,7 @@ func (s *Shell) DagPutWithOpts(data interface{}, opts ...options.DagPutOption) (
Option("input-enc", cfg.InputEnc).
Option("format", cfg.Kind).
Option("pin", cfg.Pin).
Option("hash", cfg.Hash).
Body(fileReader).
Exec(context.Background(), &out)
}
12 changes: 6 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
module github.com/TRON-US/go-btfs-api

require (
github.com/TRON-US/go-btfs-config v0.4.1
github.com/TRON-US/go-btfs-files v0.1.6
github.com/TRON-US/go-btfs-config v0.6.0
github.com/TRON-US/go-btfs-files v0.2.0
github.com/cheekybits/is v0.0.0-20150225183255-68e9c0620927
github.com/gogo/protobuf v1.3.1
github.com/ipfs/go-ipfs-util v0.0.1
github.com/libp2p/go-libp2p-core v0.0.6
github.com/libp2p/go-libp2p-core v0.5.3
github.com/libp2p/go-libp2p-metrics v0.1.0
github.com/libp2p/go-libp2p-peer v0.2.0
github.com/mitchellh/go-homedir v1.1.0
github.com/multiformats/go-multiaddr v0.0.4
github.com/multiformats/go-multiaddr-net v0.0.1
github.com/multiformats/go-multiaddr v0.2.1
github.com/multiformats/go-multiaddr-net v0.1.2
github.com/tron-us/go-btfs-common v0.3.7
github.com/tron-us/go-common/v2 v2.0.5
github.com/whyrusleeping/tar-utils v0.0.0-20180509141711-8c6c8ba81d5c
)

go 1.13

replace github.com/libp2p/go-libp2p-core => github.com/TRON-US/go-libp2p-core v0.4.1
replace github.com/libp2p/go-libp2p-core => github.com/TRON-US/go-libp2p-core v0.5.0
Loading

0 comments on commit 1918b36

Please sign in to comment.