mirror of https://github.com/waku-org/nwaku.git
chore: print WakuMessageHash as hex strings (#2969)
This commit is contained in:
parent
225b5e7260
commit
2fd4eb62fd
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue