chore: print WakuMessageHash as hex strings (#2969)

This commit is contained in:
richΛrd 2024-08-14 15:04:20 -04:00 committed by GitHub
parent 225b5e7260
commit 2fd4eb62fd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 11 additions and 0 deletions

View File

@ -8,6 +8,17 @@ import ../topics, ./message
type WakuMessageHash* = array[32, byte]
func shortLog*(hash: WakuMessageHash): string =
## Returns compact string representation of ``WakuMessageHash``.
var hexhash = newStringOfCap(13)
hexhash &= hash.toOpenArray(0, 1).to0xHex()
hexhash &= "..."
hexhash &= hash.toOpenArray(hash.len - 2, hash.high).toHex()
hexhash
func `$`*(hash: WakuMessageHash): string =
shortLog(hash)
const EmptyWakuMessageHash*: WakuMessageHash = [
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0,