Skip to content

Commit 42fd336

Browse files
committed
wip
1 parent 8aa043b commit 42fd336

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+437
-317
lines changed

dot/core/interface.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ package core
66
import (
77
"sync"
88

9-
"github.com/libp2p/go-libp2p-core/peer"
9+
"github.com/libp2p/go-libp2p/core/peer"
1010

1111
"github.com/ChainSafe/gossamer/dot/network"
1212
"github.com/ChainSafe/gossamer/dot/peerset"

dot/core/messages.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313
"github.com/ChainSafe/gossamer/lib/runtime"
1414
"github.com/ChainSafe/gossamer/lib/transaction"
1515

16-
"github.com/libp2p/go-libp2p-core/peer"
16+
"github.com/libp2p/go-libp2p/core/peer"
1717
)
1818

1919
func (s *Service) validateTransaction(peerID peer.ID, head *types.Header, rt runtime.Instance,

dot/core/messages_integration_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424
"github.com/ChainSafe/gossamer/pkg/scale"
2525

2626
"github.com/golang/mock/gomock"
27-
"github.com/libp2p/go-libp2p-core/peer"
27+
"github.com/libp2p/go-libp2p/core/peer"
2828
"github.com/stretchr/testify/require"
2929
)
3030

dot/core/messages_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import (
1717
"github.com/ChainSafe/gossamer/lib/transaction"
1818

1919
"github.com/golang/mock/gomock"
20-
"github.com/libp2p/go-libp2p-core/peer"
20+
"github.com/libp2p/go-libp2p/core/peer"
2121
"github.com/stretchr/testify/assert"
2222
)
2323

dot/core/mock_core_test.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dot/core/mocks/network_mock.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dot/network/block_announce.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
"github.com/ChainSafe/gossamer/lib/common"
1313
"github.com/ChainSafe/gossamer/pkg/scale"
1414

15-
"github.com/libp2p/go-libp2p-core/peer"
15+
"github.com/libp2p/go-libp2p/core/peer"
1616
)
1717

1818
var errInvalidRole = errors.New("invalid role")

dot/network/block_announce_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
"github.com/ChainSafe/gossamer/lib/common"
1111
"github.com/ChainSafe/gossamer/pkg/scale"
1212

13-
"github.com/libp2p/go-libp2p-core/peer"
13+
"github.com/libp2p/go-libp2p/core/peer"
1414
"github.com/stretchr/testify/require"
1515
)
1616

dot/network/compat/host.go

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
package network
2+
3+
import (
4+
"context"
5+
6+
oldconnmgr "github.com/libp2p/go-libp2p-core/connmgr"
7+
oldevent "github.com/libp2p/go-libp2p-core/event"
8+
oldhost "github.com/libp2p/go-libp2p-core/host"
9+
oldnetwork "github.com/libp2p/go-libp2p-core/network"
10+
oldpeer "github.com/libp2p/go-libp2p-core/peer"
11+
oldpeerstore "github.com/libp2p/go-libp2p-core/peerstore"
12+
oldprotocol "github.com/libp2p/go-libp2p-core/protocol"
13+
"github.com/libp2p/go-libp2p/core/host"
14+
"github.com/multiformats/go-multiaddr"
15+
)
16+
17+
func hostToDeprecated(host host.Host) (deprecated oldhost.Host) {
18+
return &deprecatedHostWrapper{host: host}
19+
}
20+
21+
type deprecatedHostWrapper struct {
22+
host host.Host
23+
}
24+
25+
func (d *deprecatedHostWrapper) ID() oldpeer.ID {
26+
return peerIDToDeprecated(d.host.ID())
27+
}
28+
29+
func (d *deprecatedHostWrapper) Peerstore() oldpeerstore.Peerstore {
30+
return peerStoreToDeprecated(d.host.Peerstore())
31+
}
32+
33+
func (d *deprecatedHostWrapper) Addrs() []multiaddr.Multiaddr {
34+
return d.host.Addrs()
35+
}
36+
37+
func (d *deprecatedHostWrapper) Network() oldnetwork.Network {
38+
return networkToDeprecated(d.host.Network())
39+
}
40+
41+
func (d *deprecatedHostWrapper) Mux() oldprotocol.Switch {
42+
return d.host.Switch()
43+
}
44+
45+
func (d *deprecatedHostWrapper) Connect(ctx context.Context, pi oldpeer.AddrInfo) error {
46+
return d.host.Connect(ctx, deprecatedPeerAddrInfoToNew(pi))
47+
}
48+
49+
func (d *deprecatedHostWrapper) SetStreamHandler(pid oldprotocol.ID, handler oldnetwork.StreamHandler) {
50+
d.host.SetStreamHandler(
51+
deprecatedProtocolIDToNew(pid), handler)
52+
}
53+
54+
func (d *deprecatedHostWrapper) SetStreamHandlerMatch(pid oldprotocol.ID,
55+
matcher func(string) bool, handler oldnetwork.StreamHandler) {
56+
d.host.SetStreamHandlerMatch(
57+
deprecatedProtocolIDToNew(pid), matcher, handler)
58+
}
59+
60+
func (d *deprecatedHostWrapper) RemoveStreamHandler(pid oldprotocol.ID) {
61+
d.host.RemoveStreamHandler(deprecatedProtocolIDToNew(pid))
62+
}
63+
64+
func (d *deprecatedHostWrapper) NewStream(ctx context.Context, p oldpeer.ID,
65+
pids ...oldprotocol.ID) (oldStream oldnetwork.Stream, err error) {
66+
stream, err := d.host.NewStream(ctx,
67+
deprecatedPeerIDToNew(p),
68+
deprecatedProtocolIDsToNew(pids)...,
69+
)
70+
if err != nil {
71+
return nil, err
72+
}
73+
return &deprecatedStreamWrapper{stream}, nil
74+
}
75+
76+
func (d *deprecatedHostWrapper) Close() error {
77+
return d.host.Close()
78+
}
79+
80+
func (d *deprecatedHostWrapper) ConnManager() oldconnmgr.ConnManager {
81+
connManager := d.host.ConnManager()
82+
return connManager
83+
}
84+
85+
func (d *deprecatedHostWrapper) EventBus() oldevent.Bus {
86+
eventBus := d.host.EventBus()
87+
return eventBus
88+
}

dot/network/compat/network.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package network
2+
3+
import (
4+
"github.com/libp2p/go-libp2p-core/network"
5+
oldnetwork "github.com/libp2p/go-libp2p-core/network"
6+
)
7+
8+
func networkToDeprecated(network network.Network) (deprecated oldnetwork.Network) {
9+
return &deprecatedNetworkWrapper{network: network}
10+
}
11+
12+
type deprecatedNetworkWrapper struct {
13+
network network.Network
14+
}

0 commit comments

Comments
 (0)