Skip to content

Commit

Permalink
update protobuf files in go-ipfs
Browse files Browse the repository at this point in the history
Also:

* Switch to gogo for filestore for consistency.
* Use the "faster" codegen for fewer allocations.

License: MIT
Signed-off-by: Steven Allen <steven@stebalien.com>
  • Loading branch information
Stebalien committed Aug 9, 2018
1 parent 594d95a commit 8993dcb
Show file tree
Hide file tree
Showing 10 changed files with 711 additions and 71 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

SHELL=PATH='$(PATH)' /bin/sh

PROTOC = protoc --gogo_out=. --proto_path=.:/usr/local/opt/protobuf/include:$(dir $@) $<
PROTOC = protoc --gogofaster_out=. --proto_path=.:$(GOPATH)/src:$(dir $@) $<

# enable second expansion
.SECONDEXPANSION:
Expand Down
3 changes: 3 additions & 0 deletions Rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ endif
dir := pin/internal/pb
include $(dir)/Rules.mk

dir := filestore/pb
include $(dir)/Rules.mk


# -------------------- #
# universal rules #
Expand Down
10 changes: 5 additions & 5 deletions filestore/fsrefstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import (
posinfo "gx/ipfs/QmSHjPDw8yNgLZ7cBfX7w3Smn7PHwYhNEpd4LHQQxUg35L/go-ipfs-posinfo"
blocks "gx/ipfs/QmVzK524a2VWLqyvtBeiHKsUAWYgeAk4DBeZoY7vpNPNRx/go-block-format"
cid "gx/ipfs/QmYVNvtQkeZ6AKSwDrjQTs432QtL6umrrK41EBq3cu7iSP/go-cid"
proto "gx/ipfs/QmZHU2gx42NPTYXzw6pJkuX6xCE7bKECp6e8QcPdoLx8sx/protobuf/proto"
dshelp "gx/ipfs/Qmd8UZEDddMaCnQ1G5eSrUhN3coX19V7SyXNQGWnAvUsnT/go-ipfs-ds-help"
proto "gx/ipfs/QmdxUuburamoF6zF9qjeQC4WYcWGbWuRmdLacMEsW8ioD8/gogo-protobuf/proto"
ds "gx/ipfs/QmeiCcJfDW1GJnWUArudsv5rQsihpi4oyddPhdqo3CfX6i/go-datastore"
dsns "gx/ipfs/QmeiCcJfDW1GJnWUArudsv5rQsihpi4oyddPhdqo3CfX6i/go-datastore/namespace"
dsq "gx/ipfs/QmeiCcJfDW1GJnWUArudsv5rQsihpi4oyddPhdqo3CfX6i/go-datastore/query"
Expand Down Expand Up @@ -281,7 +281,7 @@ func (f *FileManager) putTo(b *posinfo.FilestoreNode, to putter) error {
if !f.AllowUrls {
return ErrUrlstoreNotEnabled
}
dobj.FilePath = proto.String(b.PosInfo.FullPath)
dobj.FilePath = b.PosInfo.FullPath
} else {
if !f.AllowFiles {
return ErrFilestoreNotEnabled
Expand All @@ -295,10 +295,10 @@ func (f *FileManager) putTo(b *posinfo.FilestoreNode, to putter) error {
return err
}

dobj.FilePath = proto.String(filepath.ToSlash(p))
dobj.FilePath = filepath.ToSlash(p)
}
dobj.Offset = proto.Uint64(b.PosInfo.Offset)
dobj.Size_ = proto.Uint64(uint64(len(b.RawData())))
dobj.Offset = b.PosInfo.Offset
dobj.Size_ = uint64(len(b.RawData()))

data, err := proto.Marshal(&dobj)
if err != nil {
Expand Down
10 changes: 0 additions & 10 deletions filestore/pb/Makefile

This file was deleted.

8 changes: 8 additions & 0 deletions filestore/pb/Rules.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
include mk/header.mk

PB_$(d) = $(wildcard $(d)/*.proto)
TGTS_$(d) = $(PB_$(d):.proto=.pb.go)

#DEPS_GO += $(TGTS_$(d))

include mk/footer.mk
Loading

0 comments on commit 8993dcb

Please sign in to comment.