add hash proc to support using with containers (#516)
This commit is contained in:
parent
5aebf0990e
commit
5c234ddd37
|
@ -11,7 +11,7 @@
|
|||
|
||||
{.push raises: [Defect].}
|
||||
|
||||
import tables
|
||||
import tables, hashes
|
||||
import multibase, multicodec, multihash, vbuffer, varint
|
||||
import stew/[base58, results]
|
||||
|
||||
|
@ -268,6 +268,9 @@ proc encode*(mbtype: typedesc[MultiBase], encoding: string,
|
|||
## ``encoding``.
|
||||
result = MultiBase.encode(encoding, cid.data.buffer).tryGet()
|
||||
|
||||
proc hash*(cid: Cid): Hash {.inline.} =
|
||||
hash(cid.data.buffer)
|
||||
|
||||
proc `$`*(cid: Cid): string =
|
||||
## Return official string representation of content identifier ``cid``.
|
||||
if cid.cidver == CIDv0:
|
||||
|
|
Loading…
Reference in New Issue