Skip to content

Commit

Permalink
chore: print WakuMessageHash as hex strings (#2969)
Browse files Browse the repository at this point in the history
  • Loading branch information
richard-ramos authored Aug 14, 2024
1 parent 225b5e7 commit 2fd4eb6
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions waku/waku_core/message/digest.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 2fd4eb6

Please sign in to comment.