Skip to content
Open
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
4 changes: 2 additions & 2 deletions benchmarks/benchmark_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func BenchmarkRoundtripSuccess(b *testing.B) {

func benchmarkRepeatedDisconnects(ctx context.Context, b *testing.B, numnodes int, df distFunc, tdm *tempDirMaker) {
ctx, cancel := context.WithCancel(ctx)
mn := mocknet.New(ctx)
mn := mocknet.New()
net := tn.StreamNet(ctx, mn)
ig := testinstance.NewTestInstanceGenerator(ctx, net, nil, tdm, false)
instances, err := ig.Instances(numnodes + 1)
Expand Down Expand Up @@ -145,7 +145,7 @@ func benchmarkRepeatedDisconnects(ctx context.Context, b *testing.B, numnodes in
func p2pStrestTest(ctx context.Context, b *testing.B, numfiles int, df distFunc, tdm *tempDirMaker, options []graphsync.Option, diskBasedDatastore bool) {
ctx, cancel := context.WithCancel(ctx)
defer cancel()
mn := mocknet.New(ctx)
mn := mocknet.New()
mn.SetLinkDefaults(mocknet.LinkOptions{Latency: 100 * time.Millisecond, Bandwidth: 3000000})
net := tn.StreamNet(ctx, mn)
ig := testinstance.NewTestInstanceGenerator(ctx, net, options, tdm, diskBasedDatastore)
Expand Down
25 changes: 15 additions & 10 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ module github.com/ipfs/go-graphsync
go 1.16

require (
github.com/google/go-cmp v0.5.7
github.com/google/go-cmp v0.5.8
github.com/google/uuid v1.3.0
github.com/hannahhoward/cbor-gen-for v0.0.0-20200817222906-ea96cece81f1
github.com/hannahhoward/go-pubsub v0.0.0-20200423002714-8d62886cc36e
github.com/huin/goupnp v1.0.2 // indirect
github.com/ipfs/go-block-format v0.0.3
github.com/ipfs/go-blockservice v0.2.1
github.com/ipfs/go-cid v0.1.0
github.com/ipfs/go-datastore v0.5.0
github.com/ipfs/go-cid v0.2.0
github.com/ipfs/go-datastore v0.5.1
github.com/ipfs/go-ds-badger v0.3.0
github.com/ipfs/go-ipfs-blockstore v1.1.2
github.com/ipfs/go-ipfs-blocksutil v0.0.1
Expand All @@ -22,26 +23,30 @@ require (
github.com/ipfs/go-ipfs-routing v0.2.1
github.com/ipfs/go-ipfs-util v0.0.2
github.com/ipfs/go-ipld-format v0.2.0
github.com/ipfs/go-log/v2 v2.3.0
github.com/ipfs/go-log/v2 v2.5.1
github.com/ipfs/go-merkledag v0.5.1
github.com/ipfs/go-peertaskqueue v0.7.1
github.com/ipfs/go-unixfs v0.3.1
github.com/ipfs/go-unixfsnode v1.4.0
github.com/ipld/go-codec-dagpb v1.3.1
github.com/ipld/go-ipld-prime v0.16.0
github.com/ipld/go-ipld-prime v0.16.1-0.20220616080238-da7f58c97b04
github.com/jbenet/go-random v0.0.0-20190219211222-123a90aedc0c
github.com/koron/go-ssdp v0.0.2 // indirect
github.com/libp2p/go-buffer-pool v0.0.2
github.com/libp2p/go-libp2p v0.16.0
github.com/libp2p/go-libp2p-core v0.11.0
github.com/libp2p/go-libp2p v0.20.1
github.com/libp2p/go-libp2p-core v0.16.1
github.com/libp2p/go-libp2p-netutil v0.1.0
github.com/libp2p/go-libp2p-testing v0.5.0
github.com/libp2p/go-msgio v0.1.0
github.com/multiformats/go-multiaddr v0.4.0
github.com/libp2p/go-libp2p-peerstore v0.7.0 // indirect
github.com/libp2p/go-libp2p-testing v0.9.2
github.com/libp2p/go-msgio v0.2.0
github.com/multiformats/go-multiaddr v0.5.0
github.com/multiformats/go-multihash v0.1.0
github.com/stretchr/testify v1.7.0
go.opentelemetry.io/otel v1.2.0
go.opentelemetry.io/otel/sdk v1.2.0
go.opentelemetry.io/otel/trace v1.2.0
go.uber.org/atomic v1.9.0 // indirect
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c
google.golang.org/grpc v1.40.0 // indirect
google.golang.org/protobuf v1.27.1
)
234 changes: 139 additions & 95 deletions go.sum

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion impl/graphsync_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1928,7 +1928,7 @@ func newGsTestData(ctx context.Context, t *testing.T) *gsTestData {
func newOptionalGsTestData(ctx context.Context, t *testing.T, network1Protocols []protocol.ID, network2Protocols []protocol.ID) *gsTestData {
t.Helper()
td := &gsTestData{ctx: ctx}
td.mn = mocknet.New(ctx)
td.mn = mocknet.New()
var err error
// setup network
td.host1, err = td.mn.GenPeer()
Expand Down
12 changes: 12 additions & 0 deletions message/ipldbind/message.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
package ipldbind

import (
_ "embed"

cid "github.com/ipfs/go-cid"
"github.com/ipld/go-ipld-prime/datamodel"
bindnoderegistry "github.com/ipld/go-ipld-prime/node/bindnode/registry"

"github.com/ipfs/go-graphsync"
"github.com/ipfs/go-graphsync/message"
)

//go:embed schema.ipldsch
var embedSchema []byte

var BindnodeRegistry = bindnoderegistry.NewRegistry()

// GraphSyncExtensions is a container for representing extension data for
// bindnode, it's converted to a graphsync.ExtensionData list by
// ToExtensionsList()
Expand Down Expand Up @@ -95,3 +103,7 @@ type NamedExtension struct {
Name graphsync.ExtensionName
Data datamodel.Node
}

func init() {
BindnodeRegistry.RegisterType((*GraphSyncMessageRoot)(nil), string(embedSchema), "GraphSyncMessageRoot")
}
25 changes: 0 additions & 25 deletions message/ipldbind/schema.go

This file was deleted.

9 changes: 2 additions & 7 deletions message/v2/ipld_roundtrip_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@ import (

blocks "github.com/ipfs/go-block-format"
"github.com/ipfs/go-cid"
"github.com/ipld/go-ipld-prime"
"github.com/ipld/go-ipld-prime/codec/dagcbor"
"github.com/ipld/go-ipld-prime/datamodel"
"github.com/ipld/go-ipld-prime/node/basicnode"
"github.com/ipld/go-ipld-prime/node/bindnode"
selectorparse "github.com/ipld/go-ipld-prime/traversal/selector/parse"
"github.com/stretchr/testify/require"

Expand Down Expand Up @@ -65,15 +63,12 @@ func TestIPLDRoundTrip(t *testing.T) {
require.NoError(t, err)

// ipld TypedNode format
node := bindnode.Wrap(igsm, ipldbind.Prototype.Message.Type())
byts, err := ipld.Encode(node, dagcbor.Encode)
// dag-cbor binary format
byts, err := ipldbind.BindnodeRegistry.TypeToBytes(igsm, dagcbor.Encode)
require.NoError(t, err)

// back to bindnode internal format
rtnode, err := ipld.DecodeUsingPrototype(byts, dagcbor.Decode, ipldbind.Prototype.Message.Representation())
rtigsm, err := ipldbind.BindnodeRegistry.TypeFromBytes(byts, (*ipldbind.GraphSyncMessageRoot)(nil), dagcbor.Decode)
require.NoError(t, err)
rtigsm := bindnode.Unwrap(rtnode)

// back to message format
rtgsm, err := NewMessageHandler().fromIPLD(rtigsm.(*ipldbind.GraphSyncMessageRoot))
Expand Down
9 changes: 2 additions & 7 deletions message/v2/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"github.com/ipld/go-ipld-prime"
"github.com/ipld/go-ipld-prime/codec/dagcbor"
"github.com/ipld/go-ipld-prime/datamodel"
"github.com/ipld/go-ipld-prime/node/bindnode"
"github.com/libp2p/go-libp2p-core/network"
"github.com/libp2p/go-libp2p-core/peer"
"github.com/libp2p/go-msgio"
Expand Down Expand Up @@ -44,11 +43,7 @@ func (mh *MessageHandler) FromMsgReader(_ peer.ID, r msgio.Reader) (message.Grap
return message.GraphSyncMessage{}, err
}

node, err := ipld.DecodeUsingPrototype(msg, dagcbor.Decode, ipldbind.Prototype.Message.Representation())
if err != nil {
return message.GraphSyncMessage{}, err
}
ipldGSM := bindnode.Unwrap(node)
ipldGSM, err := ipldbind.BindnodeRegistry.TypeFromBytes(msg, (*ipldbind.GraphSyncMessageRoot)(nil), dagcbor.Decode)
if err != nil {
return message.GraphSyncMessage{}, err
}
Expand Down Expand Up @@ -140,7 +135,7 @@ func (mh *MessageHandler) ToNet(_ peer.ID, gsm message.GraphSyncMessage, w io.Wr
buf := new(bytes.Buffer)
buf.Write(lbuf)

node := bindnode.Wrap(msg, ipldbind.Prototype.Message.Type())
node := ipldbind.BindnodeRegistry.TypeToNode(msg)
err = ipld.EncodeStreaming(buf, node.Representation(), dagcbor.Encode)
if err != nil {
return err
Expand Down
2 changes: 2 additions & 0 deletions network/libp2p_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,8 @@ func (gsnet *libp2pGraphSyncNetwork) SendMessage(
return err
}

time.Sleep(100 * time.Millisecond)

return s.Close()
}

Expand Down
2 changes: 1 addition & 1 deletion network/libp2p_impl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func TestMessageSendAndReceive(t *testing.T) {
ctx := context.Background()
ctx, cancel := context.WithTimeout(ctx, 10*time.Second)
defer cancel()
mn := mocknet.New(ctx)
mn := mocknet.New()

host1, err := mn.GenPeer()
require.NoError(t, err)
Expand Down