Browse Source

Use base 36 when generating message IDs, gives us full 0-9a-z to use while preserving uniqueness nicely

tags/v0.11.0-alpha
Daniel Oaks 6 years ago
parent
commit
3ba8af714e
1 changed files with 3 additions and 3 deletions
  1. 3
    3
      irc/server.go

+ 3
- 3
irc/server.go View File

397
 func (server *Server) generateMessageID() string {
397
 func (server *Server) generateMessageID() string {
398
 	// we don't need the full like 30 chars since the unixnano below handles
398
 	// we don't need the full like 30 chars since the unixnano below handles
399
 	// most of our uniqueness requirements, so just truncate at 5
399
 	// most of our uniqueness requirements, so just truncate at 5
400
-	lastbit := strconv.FormatInt(rand.Int63(), 16)
400
+	lastbit := strconv.FormatInt(rand.Int63(), 36)
401
 	if 5 < len(lastbit) {
401
 	if 5 < len(lastbit) {
402
-		lastbit = lastbit[:5]
402
+		lastbit = lastbit[:4]
403
 	}
403
 	}
404
-	return fmt.Sprintf("%s%s", strconv.FormatInt(time.Now().UTC().UnixNano(), 16), lastbit)
404
+	return fmt.Sprintf("%s%s", strconv.FormatInt(time.Now().UTC().UnixNano(), 36), lastbit)
405
 }
405
 }
406
 
406
 
407
 //
407
 //

Loading…
Cancel
Save