Skip to content
This repository was archived by the owner on Sep 6, 2022. It is now read-only.

Commit 13e0150

Browse files
remove OpenedStream and ClosedStream from Notifiee interface (#250)
* remove TODO for PeerConnected and PeerDisconnected from Notifiee This is now done via the event bus. * remove OpenedStream and ClosedStream from Notifiee
1 parent 02cbdcc commit 13e0150

File tree

2 files changed

+0
-61
lines changed

2 files changed

+0
-61
lines changed

network/notifee.go

-25
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,6 @@ type Notifiee interface {
1111
ListenClose(Network, ma.Multiaddr) // called when network stops listening on an addr
1212
Connected(Network, Conn) // called when a connection opened
1313
Disconnected(Network, Conn) // called when a connection closed
14-
OpenedStream(Network, Stream) // called when a stream opened
15-
ClosedStream(Network, Stream) // called when a stream closed
16-
17-
// TODO
18-
// PeerConnected(Network, peer.ID) // called when a peer connected
19-
// PeerDisconnected(Network, peer.ID) // called when a peer disconnected
2014
}
2115

2216
// NotifyBundle implements Notifiee by calling any of the functions set on it,
@@ -28,9 +22,6 @@ type NotifyBundle struct {
2822

2923
ConnectedF func(Network, Conn)
3024
DisconnectedF func(Network, Conn)
31-
32-
OpenedStreamF func(Network, Stream)
33-
ClosedStreamF func(Network, Stream)
3425
}
3526

3627
var _ Notifiee = (*NotifyBundle)(nil)
@@ -63,20 +54,6 @@ func (nb *NotifyBundle) Disconnected(n Network, c Conn) {
6354
}
6455
}
6556

66-
// OpenedStream calls OpenedStreamF if it is not null.
67-
func (nb *NotifyBundle) OpenedStream(n Network, s Stream) {
68-
if nb.OpenedStreamF != nil {
69-
nb.OpenedStreamF(n, s)
70-
}
71-
}
72-
73-
// ClosedStream calls ClosedStreamF if it is not null.
74-
func (nb *NotifyBundle) ClosedStream(n Network, s Stream) {
75-
if nb.ClosedStreamF != nil {
76-
nb.ClosedStreamF(n, s)
77-
}
78-
}
79-
8057
// Global noop notifiee. Do not change.
8158
var GlobalNoopNotifiee = &NoopNotifiee{}
8259

@@ -88,5 +65,3 @@ func (nn *NoopNotifiee) Connected(n Network, c Conn) {}
8865
func (nn *NoopNotifiee) Disconnected(n Network, c Conn) {}
8966
func (nn *NoopNotifiee) Listen(n Network, addr ma.Multiaddr) {}
9067
func (nn *NoopNotifiee) ListenClose(n Network, addr ma.Multiaddr) {}
91-
func (nn *NoopNotifiee) OpenedStream(Network, Stream) {}
92-
func (nn *NoopNotifiee) ClosedStream(Network, Stream) {}

network/notifee_test.go

-36
Original file line numberDiff line numberDiff line change
@@ -85,39 +85,3 @@ func TestDisconnected(T *testing.T) {
8585
T.Fatal("Disconnected should have been called")
8686
}
8787
}
88-
89-
func TestOpenedStream(T *testing.T) {
90-
var notifee NotifyBundle
91-
notifee.OpenedStream(nil, nil)
92-
93-
called := false
94-
notifee.OpenedStreamF = func(Network, Stream) {
95-
called = true
96-
}
97-
if called {
98-
T.Fatal("called should be false")
99-
}
100-
101-
notifee.OpenedStream(nil, nil)
102-
if !called {
103-
T.Fatal("OpenedStream should have been called")
104-
}
105-
}
106-
107-
func TestClosedStream(T *testing.T) {
108-
var notifee NotifyBundle
109-
notifee.ClosedStream(nil, nil)
110-
111-
called := false
112-
notifee.ClosedStreamF = func(Network, Stream) {
113-
called = true
114-
}
115-
if called {
116-
T.Fatal("called should be false")
117-
}
118-
119-
notifee.ClosedStream(nil, nil)
120-
if !called {
121-
T.Fatal("ClosedStream should have been called")
122-
}
123-
}

0 commit comments

Comments
 (0)