Skip to content

Commit 74605c8

Browse files
authored
Merge pull request #37 from kaleido-io/reply-chl-depth
Move 10 depth to correct channel, for spurious ack processing
2 parents 2b04955 + 91abb30 commit 74605c8

File tree

4 files changed

+10
-4
lines changed

4 files changed

+10
-4
lines changed

internal/confirmations/confirmations.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ func (pi *pendingItem) getKey() string {
150150
case pendingTypeEvent:
151151
// For events they are identified by their hash, blockNumber, transactionIndex and logIndex
152152
// If any of those change, it's a new new event - and as such we should get informed of it separately by the blockchain connector.
153-
return fmt.Sprintf("Event:l=%s,th=%s,bh=%s,bn=%d,ti=%d,li=%d", pi.listenerID, pi.transactionHash, pi.blockHash, pi.blockNumber, pi.transactionIndex, pi.logIndex)
153+
return fmt.Sprintf("Event:%.12d/%.6d/%.6d,l=%s,th=%s,bh=%s", pi.blockNumber, pi.transactionIndex, pi.logIndex, pi.listenerID, pi.transactionHash, pi.blockHash)
154154
case pendingTypeTransaction:
155155
// For transactions, it's simply the transaction hash that identifies it. It can go into any block
156156
return pendingKeyForTX(pi.transactionHash)

internal/ws/wsconn.go

-2
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ type webSocketConnection struct {
3939
topics map[string]*webSocketTopic
4040
broadcast chan interface{}
4141
newTopic chan bool
42-
receive chan *WebSocketCommandMessageOrError
4342
closing chan struct{}
4443
}
4544

@@ -66,7 +65,6 @@ func newConnection(bgCtx context.Context, server *webSocketServer, conn *ws.Conn
6665
newTopic: make(chan bool),
6766
topics: make(map[string]*webSocketTopic),
6867
broadcast: make(chan interface{}),
69-
receive: make(chan *WebSocketCommandMessageOrError, 10),
7068
closing: make(chan struct{}),
7169
}
7270
go wsc.listen()

internal/ws/wsserver.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ func (s *webSocketServer) getTopic(topic string) *webSocketTopic {
132132
topic: topic,
133133
senderChannel: make(chan interface{}),
134134
broadcastChannel: make(chan interface{}),
135-
receiverChannel: make(chan *WebSocketCommandMessageOrError, 1),
135+
receiverChannel: make(chan *WebSocketCommandMessageOrError, 10),
136136
}
137137
s.topics[topic] = t
138138
s.topicMap[topic] = make(map[string]*webSocketConnection)

internal/ws/wsserver_test.go

+8
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,10 @@ func TestSpuriousAckProcessing(t *testing.T) {
189189
c, _, err := ws.DefaultDialer.Dial(u.String(), nil)
190190
assert.NoError(err)
191191

192+
// Drop depth to 1 for spurious ack processing
193+
topic := w.getTopic("mytopic")
194+
topic.receiverChannel = make(chan *WebSocketCommandMessageOrError, 1)
195+
192196
c.WriteJSON(&WebSocketCommandMessage{
193197
Type: "ack",
194198
Topic: "mytopic",
@@ -217,6 +221,10 @@ func TestSpuriousNackProcessing(t *testing.T) {
217221
c, _, err := ws.DefaultDialer.Dial(u.String(), nil)
218222
assert.NoError(err)
219223

224+
// Drop depth to 1 for spurious ack processing
225+
topic := w.getTopic("mytopic")
226+
topic.receiverChannel = make(chan *WebSocketCommandMessageOrError, 1)
227+
220228
c.WriteJSON(&WebSocketCommandMessage{
221229
Type: "ack",
222230
Topic: "mytopic",

0 commit comments

Comments
 (0)