From 9a23bd5523b06c0da2731a332ad7b329c8e3355f Mon Sep 17 00:00:00 2001 From: Emiliano Ciavatta Date: Fri, 10 Jul 2020 12:19:54 +0200 Subject: Fix stream content order bug --- connection_streams_controller.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/connection_streams_controller.go b/connection_streams_controller.go index 6c6c962..251e842 100644 --- a/connection_streams_controller.go +++ b/connection_streams_controller.go @@ -77,8 +77,9 @@ func (csc ConnectionStreamsController) GetConnectionPayload(c context.Context, c var payload Payload for !clientStream.ID.IsZero() || !serverStream.ID.IsZero() { - if hasClientBlocks() && !(hasServerBlocks() && // next payload is from client - clientStream.BlocksTimestamps[0].UnixNano() > serverStream.BlocksTimestamps[0].UnixNano()) { + if hasClientBlocks() && (!hasServerBlocks() || // next payload is from client + clientStream.BlocksTimestamps[clientBlocksIndex].UnixNano() <= + serverStream.BlocksTimestamps[serverBlocksIndex].UnixNano()) { start := clientStream.BlocksIndexes[clientBlocksIndex] end := 0 if clientBlocksIndex < len(clientStream.BlocksIndexes)-1 { -- cgit v1.2.3-70-g09d2