Closed tromp closed 6 years ago
fold1
is a part itertools
which is an external crate used in grin
crate but not (yet?) in core
. Is it ok to add as an additional dependency to core
?
With regular fold
code is just a bit shorter, smth like
return self.root == self.peaks.iter().fold(ZERO_HASH, |b, &p| {
if b == ZERO_HASH {
p
} else {
b.hash_with(p)
}
});
@hashmap I'm a bit unhappy with adding dependencie in general. For this specific case, maybe the code above might get replaced anyway
code to be obsoleted in https://github.com/mimblewimble/grin/issues/797
pmmr.rs lines 215..221 read
This is folding the function hash_with over the elements of self.peaks, which should be a one liner using the rust function fold1