add 'BloomFilter.init' implementation

This commit is contained in:
jangko 2020-09-30 12:04:23 +07:00
parent 0194fb85eb
commit 6c0bc31ad6
No known key found for this signature in database
GPG Key ID: 31702AE10541E6B9
1 changed files with 3 additions and 0 deletions

View File

@ -23,6 +23,9 @@ proc incl*(f: var BloomFilter, h: MDigest[256]) =
for bits in bloomBits(h):
f.value = f.value or bits
proc init*(_: type BloomFilter, h: MDigest[256]): BloomFilter =
result.incl(h)
# TODO: The following 2 procs should be one genric, but it doesn't compile. Nim bug?
proc incl*(f: var BloomFilter, v: string) = f.incl(keccak256.digest(v))
proc incl*(f: var BloomFilter, v: openarray[byte]) = f.incl(keccak256.digest(v))