Skip to content

Commit

Permalink
Remove Support for data-transfer/graphsync
Browse files Browse the repository at this point in the history
Support for sync over datatransfer/graphsync has been removed.
  • Loading branch information
gammazero committed Dec 27, 2023
1 parent f8c9474 commit f7daf14
Show file tree
Hide file tree
Showing 20 changed files with 30 additions and 1,702 deletions.
2 changes: 1 addition & 1 deletion announce/p2psender/option.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
pubsub "github.com/libp2p/go-libp2p-pubsub"
)

// config contains all options for configuring dtsync.publisher.
// config contains all options for configuring ipnisync.publisher.
type config struct {
topic *pubsub.Topic
extraData []byte
Expand Down
80 changes: 0 additions & 80 deletions dagsync/announce_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package dagsync_test

import (
"context"
"sync"
"testing"
"time"

Expand All @@ -17,7 +16,6 @@ import (
"github.com/ipni/go-libipni/announce"
"github.com/ipni/go-libipni/announce/p2psender"
"github.com/ipni/go-libipni/dagsync"
"github.com/ipni/go-libipni/dagsync/dtsync"
"github.com/ipni/go-libipni/dagsync/ipnisync"
"github.com/ipni/go-libipni/dagsync/test"
"github.com/libp2p/go-libp2p/core/host"
Expand Down Expand Up @@ -344,84 +342,6 @@ func TestAllowPeerAllows(t *testing.T) {
}
}

func TestPublisherRejectsPeer(t *testing.T) {
t.Parallel()
// Init dagsync publisher and subscriber
srcStore := dssync.MutexWrap(datastore.NewMapDatastore())
dstStore := dssync.MutexWrap(datastore.NewMapDatastore())

srcHost := test.MkTestHost(t)
dstHost := test.MkTestHost(t)

topics := test.WaitForMeshWithMessage(t, testTopic, srcHost, dstHost)

srcLnkS := test.MkLinkSystem(srcStore)

blockID := dstHost.ID()
var blockMutex sync.Mutex

allowPeer := func(peerID peer.ID) bool {
blockMutex.Lock()
defer blockMutex.Unlock()
return peerID != blockID
}

p2pSender, err := p2psender.New(nil, "", p2psender.WithTopic(topics[0]))
require.NoError(t, err)

pub, err := dtsync.NewPublisher(srcHost, srcStore, srcLnkS, testTopic, dtsync.WithAllowPeer(allowPeer))
require.NoError(t, err)
defer pub.Close()

srcHost.Peerstore().AddAddrs(dstHost.ID(), dstHost.Addrs(), time.Hour)
dstHost.Peerstore().AddAddrs(srcHost.ID(), srcHost.Addrs(), time.Hour)
dstLnkS := test.MkLinkSystem(dstStore)

sub, err := dagsync.NewSubscriber(dstHost, dstStore, dstLnkS, testTopic, dagsync.RecvAnnounce(announce.WithTopic(topics[1])))
require.NoError(t, err)
defer sub.Close()

err = srcHost.Connect(context.Background(), dstHost.Peerstore().PeerInfo(dstHost.ID()))
require.NoError(t, err)

require.NoError(t, test.WaitForP2PPublisher(pub, dstHost, testTopic))

watcher, cncl := sub.OnSyncFinished()
defer cncl()

c := mkLnk(t, srcStore)

// Update root with item
pub.SetRoot(c)
err = announce.Send(context.Background(), c, pub.Addrs(), p2pSender)
require.NoError(t, err)

select {
case <-time.After(updateTimeout):
t.Log("publisher blocked")
case <-watcher:
t.Fatal("sync should not have happened with blocked ID")
}

blockMutex.Lock()
blockID = peer.ID("")
blockMutex.Unlock()

c = mkLnk(t, srcStore)

// Update root with item
pub.SetRoot(c)
err = announce.Send(context.Background(), c, pub.Addrs(), p2pSender)
require.NoError(t, err)

select {
case <-time.After(updateTimeout):
t.Fatal("timed out waiting for SyncFinished")
case <-watcher:
t.Log("synced with allowed ID")
}
}

func mkLnk(t *testing.T, srcStore datastore.Batching) cid.Cid {
// Update root with item
np := basicnode.Prototype__Any{}
Expand Down
176 changes: 0 additions & 176 deletions dagsync/dtsync/head/head.go

This file was deleted.

99 changes: 0 additions & 99 deletions dagsync/dtsync/head/head_test.go

This file was deleted.

Loading

0 comments on commit f7daf14

Please sign in to comment.