Skip to content

Commit ef853ae

Browse files
Update croaring (#3233)
1 parent 6bca34c commit ef853ae

File tree

8 files changed

+207
-221
lines changed

8 files changed

+207
-221
lines changed

.ci/install.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ steps:
1212
condition: eq( variables['Agent.OS'], 'Darwin' )
1313
- script: |
1414
sudo apt-get update -yqq
15-
sudo apt-get install -yqq --no-install-recommends libncursesw5-dev
15+
sudo apt-get install -yqq --no-install-recommends libncursesw5-dev libclang-dev clang
1616
displayName: Linux Install Dependencies
1717
condition: eq( variables['Agent.OS'], 'Linux' )

Cargo.lock

Lines changed: 63 additions & 63 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

chain/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ bitflags = "1"
1515
byteorder = "1"
1616
failure = "0.1"
1717
failure_derive = "0.1"
18-
croaring = "0.3.9"
18+
croaring = "0.4"
1919
log = "0.4"
2020
serde = "1"
2121
serde_derive = "1"

core/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ edition = "2018"
1212
[dependencies]
1313
blake2 = { package = "blake2-rfc", version = "0.2"}
1414
byteorder = "1"
15-
croaring = "0.3.9"
15+
croaring = "0.4"
1616
enum_primitive = "0.1"
1717
failure = "0.1"
1818
failure_derive = "0.1"

core/fuzz/Cargo.lock

Lines changed: 132 additions & 147 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

store/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ edition = "2018"
1111

1212
[dependencies]
1313
byteorder = "1"
14-
croaring = "0.3.9"
14+
croaring = "0.4"
1515
libc = "0.2"
1616
failure = "0.1"
1717
failure_derive = "0.1"

store/src/leaf_set.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ impl LeafSet {
114114

115115
// First remove pos from leaf_set that were
116116
// added after the point we are rewinding to.
117-
let to_remove = ((cutoff_pos + 1) as u32)..bitmap.maximum();
117+
let to_remove = ((cutoff_pos + 1) as u32)..bitmap.maximum().unwrap_or(0);
118118
bitmap.remove_range_closed(to_remove);
119119

120120
// Then add back output pos to the leaf_set
@@ -133,7 +133,7 @@ impl LeafSet {
133133
pub fn rewind(&mut self, cutoff_pos: u64, rewind_rm_pos: &Bitmap) {
134134
// First remove pos from leaf_set that were
135135
// added after the point we are rewinding to.
136-
let to_remove = ((cutoff_pos + 1) as u32)..self.bitmap.maximum();
136+
let to_remove = ((cutoff_pos + 1) as u32)..self.bitmap.maximum().unwrap_or(0);
137137
self.bitmap.remove_range_closed(to_remove);
138138

139139
// Then add back output pos to the leaf_set

store/src/prune_list.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -131,13 +131,13 @@ impl PruneList {
131131
/// Return the total shift from all entries in the prune_list.
132132
/// This is the shift we need to account for when adding new entries to our PMMR.
133133
pub fn get_total_shift(&self) -> u64 {
134-
self.get_shift(self.bitmap.maximum() as u64)
134+
self.get_shift(self.bitmap.maximum().unwrap_or(0) as u64)
135135
}
136136

137137
/// Return the total leaf_shift from all entries in the prune_list.
138138
/// This is the leaf_shift we need to account for when adding new entries to our PMMR.
139139
pub fn get_total_leaf_shift(&self) -> u64 {
140-
self.get_leaf_shift(self.bitmap.maximum() as u64)
140+
self.get_leaf_shift(self.bitmap.maximum().unwrap_or(0) as u64)
141141
}
142142

143143
/// Computes by how many positions a node at pos should be shifted given the
@@ -276,9 +276,10 @@ impl PruneList {
276276
if self.bitmap.is_empty() {
277277
return;
278278
}
279-
self.pruned_cache = Bitmap::create_with_capacity(self.bitmap.maximum());
280-
for pos in 1..=self.bitmap.maximum() {
281-
let path = path(pos as u64, self.bitmap.maximum() as u64);
279+
let maximum = self.bitmap.maximum().unwrap_or(0);
280+
self.pruned_cache = Bitmap::create_with_capacity(maximum);
281+
for pos in 1..(maximum + 1) {
282+
let path = path(pos as u64, maximum as u64);
282283
let pruned = path.into_iter().any(|x| self.bitmap.contains(x as u32));
283284
if pruned {
284285
self.pruned_cache.add(pos as u32)

0 commit comments

Comments
 (0)