Skip to content

Commit

Permalink
Update blockchain.go
Browse files Browse the repository at this point in the history
  • Loading branch information
ehsan6sha committed Feb 3, 2025
1 parent 410ba0d commit 8c0d74a
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions mobile/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,20 +282,22 @@ func (c *Client) GetChatChunk(streamID string) (string, error) {
c.mu.Unlock()

if !ok {
fmt.Printf("GetChatChunk: Invalid stream ID: %s", streamID)
return "", fmt.Errorf("invalid stream ID")
}

chunk, err := buffer.GetChunk()
if err != nil { // Stream closed or errored out
fmt.Printf("GetChatChunk: Stream closed for ID: %s", streamID)
c.mu.Lock()
delete(c.streams, streamID) // Remove the stream from the map
c.mu.Unlock()
return "", err
}

fmt.Printf("GetChatChunk: Returning chunk: %s", chunk)
// Ensure empty chunks are not returned
if chunk == "" {
return "", nil // Return nil error for empty chunk
}

return chunk, nil
}

Expand Down

0 comments on commit 8c0d74a

Please sign in to comment.