block-checksum-state


Vocabulary
checksums.common

Definition


Methods

M:: block-checksum-state add-checksum-bytes
( state data -- checksum-state )
state bytes>> :> bytes state block-size>> :> block-size
bytes
[ data ] [
length :> initial-len block-size initial-len -
:> needed needed 0 > t assert=
data dup length needed min cut-slice [
state over length [ + ] curry change-bytes-read drop
bytes push-all bytes length block-size =
[ bytes state checksum-block bytes delete-all ] when
] dip
] if-empty dup length block-size mod cut-slice* [
block-size <groups> [
bytes push-all bytes state
[ block-size + ] change-bytes-read checksum-block
bytes delete-all
] each
] [
[ bytes push-all ]
[ state swap length [ + ] curry change-bytes-read ] bi
] bi* ;