mirror of
https://github.com/ipfs/kubo.git
synced 2025-07-04 05:16:23 +08:00
refactor(net/service) move proto to internal pb package
This commit is contained in:
@ -4,6 +4,7 @@ import (
|
|||||||
crand "crypto/rand"
|
crand "crypto/rand"
|
||||||
|
|
||||||
msg "github.com/jbenet/go-ipfs/net/message"
|
msg "github.com/jbenet/go-ipfs/net/message"
|
||||||
|
pb "github.com/jbenet/go-ipfs/net/service/internal/pb"
|
||||||
peer "github.com/jbenet/go-ipfs/peer"
|
peer "github.com/jbenet/go-ipfs/peer"
|
||||||
|
|
||||||
proto "github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/goprotobuf/proto"
|
proto "github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/goprotobuf/proto"
|
||||||
@ -104,7 +105,7 @@ func RequestKey(pid peer.ID, rid RequestID) string {
|
|||||||
|
|
||||||
func wrapData(data []byte, rid RequestID) ([]byte, error) {
|
func wrapData(data []byte, rid RequestID) ([]byte, error) {
|
||||||
// Marshal
|
// Marshal
|
||||||
pbm := new(PBRequest)
|
pbm := new(pb.PBRequest)
|
||||||
pbm.Data = data
|
pbm.Data = data
|
||||||
pbm.Tag = rid
|
pbm.Tag = rid
|
||||||
b, err := proto.Marshal(pbm)
|
b, err := proto.Marshal(pbm)
|
||||||
@ -117,7 +118,7 @@ func wrapData(data []byte, rid RequestID) ([]byte, error) {
|
|||||||
|
|
||||||
func unwrapData(data []byte) ([]byte, RequestID, error) {
|
func unwrapData(data []byte) ([]byte, RequestID, error) {
|
||||||
// Unmarshal
|
// Unmarshal
|
||||||
pbm := new(PBRequest)
|
pbm := new(pb.PBRequest)
|
||||||
err := proto.Unmarshal(data, pbm)
|
err := proto.Unmarshal(data, pbm)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
|
Reference in New Issue
Block a user