bip158: added profiling hints
/- bc=bitcoin
/+ bcu=bitcoin-utils
+~% %bip-158-top ..part ~
|%
++ params
|%
--
::
++ siphash
+ ~/ %siphash
|= [k=byts m=byts]
^- byts
|^
:: write appends to the back
::
++ str
+ ~/ %str
|%
++ read-bit
|= s=bits:bc
:: +gol: Golomb-Rice encoding/decoding
::
++ gol
+ ~% %gol ..params ~
|%
:: +en: encode x and append to end of s
:: - s: bits stream
:: - p: golomb-rice p param
::
++ en
+ ~/ %en
|= [s=bits:bc x=@ p=@]
^- bits:bc
=+ q=(rsh [0 p] x)
(write-bits:str unary r)
::
++ de
+ ~/ %de
|= [s=bits:bc p=@]
^- [delta=@ rest=bits:bc]
|^ ?> (gth wid.s 0)
:: +hsh
::
++ hsh
+ ~% %hsh ..params ~
|%
:: +to-range
:: - item: scriptpubkey to hash
:: - k: key for siphash (end of blockhash, reversed)
::
++ to-range
+ ~/ %to-range
|= [item=byts f=@ k=byts]
^- @
(rsh [0 64] (mul f (swp 3 dat:(siphash k item))))
--
::
++ parse-filter
+ ~/ %parse-filter
|= filter=hexb:bc
^- [n=@ux gcs-set=bits:bc]
=/ n n:(de:csiz:bcu filter)
:: +to-key: blockhash (little endian) to key for siphash
::
++ to-key
+ ~/ %to-key
|= blockhash=tape
^- byts
%+ take:byt:bcu 16
:: - targets: scriptpubkeys to match
::
++ match
+ ~/ %match
|= [filter=hexb:bc k=byts targets=(list byts)]
^- ?
=/ [p=@ m=@] [p:params m:params]
:: - targets: scriptpubkeys to match
::
++ all-match
+ ~/ %all-match
|= [filter=hexb:bc blockhash=hexb:bc targets=(list [address:bc byts])]
^- (set [address:bc hexb:bc])
=/ k (to-key (trip (to-cord:hxb:bcu blockhash)))
