Skip to content

Commit

Permalink
fix parsing COUNT envelopes without "hll".
Browse files Browse the repository at this point in the history
  • Loading branch information
fiatjaf committed Dec 7, 2024
1 parent 142da73 commit e8d9464
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion envelopes.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,12 @@ func (v *CountEnvelope) UnmarshalJSON(data []byte) error {
}
if err := json.Unmarshal([]byte(arr[2].Raw), &countResult); err == nil && countResult.Count != nil {
v.Count = countResult.Count
v.HyperLogLog, _ = hex.DecodeString(countResult.HLL)
if len(countResult.HLL) == 512 {
v.HyperLogLog, err = hex.DecodeString(countResult.HLL)
if err != nil {
return fmt.Errorf("invalid \"hll\" value in COUNT message: %w", err)
}
}
return nil
}

Expand Down

0 comments on commit e8d9464

Please sign in to comment.