Skip to content

Commit 37287ea

Browse files
authored
p2p: remove message type from channel implementation (tendermint#8452)
1 parent 6c40ad3 commit 37287ea

File tree

5 files changed

+8
-21
lines changed

5 files changed

+8
-21
lines changed

internal/p2p/channel.go

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -59,25 +59,17 @@ type Channel struct {
5959
outCh chan<- Envelope // outbound messages (reactors to peers)
6060
errCh chan<- PeerError // peer error reporting
6161

62-
messageType proto.Message // the channel's message type, used for unmarshaling
63-
name string
62+
name string
6463
}
6564

6665
// NewChannel creates a new channel. It is primarily for internal and test
6766
// use, reactors should use Router.OpenChannel().
68-
func NewChannel(
69-
id ChannelID,
70-
messageType proto.Message,
71-
inCh <-chan Envelope,
72-
outCh chan<- Envelope,
73-
errCh chan<- PeerError,
74-
) *Channel {
67+
func NewChannel(id ChannelID, inCh <-chan Envelope, outCh chan<- Envelope, errCh chan<- PeerError) *Channel {
7568
return &Channel{
76-
ID: id,
77-
messageType: messageType,
78-
inCh: inCh,
79-
outCh: outCh,
80-
errCh: errCh,
69+
ID: id,
70+
inCh: inCh,
71+
outCh: outCh,
72+
errCh: errCh,
8173
}
8274
}
8375

internal/p2p/pex/reactor_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,6 @@ func setupSingle(ctx context.Context, t *testing.T) *singleTestReactor {
289289
pexErrCh := make(chan p2p.PeerError, chBuf)
290290
pexCh := p2p.NewChannel(
291291
p2p.ChannelID(pex.PexChannel),
292-
new(p2pproto.PexMessage),
293292
pexInCh,
294293
pexOutCh,
295294
pexErrCh,

internal/p2p/router.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ func (r *Router) OpenChannel(ctx context.Context, chDesc *ChannelDescriptor) (*C
262262
queue := r.queueFactory(chDesc.RecvBufferCapacity)
263263
outCh := make(chan Envelope, chDesc.RecvBufferCapacity)
264264
errCh := make(chan PeerError, chDesc.RecvBufferCapacity)
265-
channel := NewChannel(id, messageType, queue.dequeue(), outCh, errCh)
265+
channel := NewChannel(id, queue.dequeue(), outCh, errCh)
266266
channel.name = chDesc.Name
267267

268268
var wrapper Wrapper

internal/statesync/dispatcher_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func testChannel(size int) (*channelInternal, *p2p.Channel) {
3030
Out: make(chan p2p.Envelope, size),
3131
Error: make(chan p2p.PeerError, size),
3232
}
33-
return in, p2p.NewChannel(0, nil, in.In, in.Out, in.Error)
33+
return in, p2p.NewChannel(0, in.In, in.Out, in.Error)
3434
}
3535

3636
func TestDispatcherBasic(t *testing.T) {

internal/statesync/reactor_test.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,31 +102,27 @@ func setup(
102102

103103
rts.snapshotChannel = p2p.NewChannel(
104104
SnapshotChannel,
105-
new(ssproto.Message),
106105
rts.snapshotInCh,
107106
rts.snapshotOutCh,
108107
rts.snapshotPeerErrCh,
109108
)
110109

111110
rts.chunkChannel = p2p.NewChannel(
112111
ChunkChannel,
113-
new(ssproto.Message),
114112
rts.chunkInCh,
115113
rts.chunkOutCh,
116114
rts.chunkPeerErrCh,
117115
)
118116

119117
rts.blockChannel = p2p.NewChannel(
120118
LightBlockChannel,
121-
new(ssproto.Message),
122119
rts.blockInCh,
123120
rts.blockOutCh,
124121
rts.blockPeerErrCh,
125122
)
126123

127124
rts.paramsChannel = p2p.NewChannel(
128125
ParamsChannel,
129-
new(ssproto.Message),
130126
rts.paramsInCh,
131127
rts.paramsOutCh,
132128
rts.paramsPeerErrCh,

0 commit comments

Comments
 (0)