Skip to content

Commit a14d1e1

Browse files
authored
update croaring (#61)
1 parent 29f8fa8 commit a14d1e1

17 files changed

+93
-191
lines changed

Cargo.lock

+4-102
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

azure-pipelines.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ jobs:
7676
- template: '.ci/release.yml'
7777
- job: windows
7878
pool:
79-
vmImage: windows-latest
79+
vmImage: windows-2019
8080
strategy:
8181
matrix:
8282
test:

chain/Cargo.toml

+1-1
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.5.2"
18+
croaring = "1.0.1"
1919
enum_primitive = "0.1"
2020
log = "0.4"
2121
serde = "1"

chain/src/store.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use crate::linked_list::MultiIndex;
2323
use crate::types::{CommitPos, HashHeight, Tip};
2424
use crate::util::secp::pedersen::Commitment;
2525

26-
use croaring::Bitmap;
26+
use croaring::{Bitmap, Portable};
2727
use grin_store as store;
2828
use grin_store::{option_to_not_found, to_key, Error, SerIterator};
2929
use std::convert::TryInto;
@@ -436,8 +436,10 @@ impl<'a> Batch<'a> {
436436

437437
fn get_legacy_input_bitmap(&self, bh: &Hash) -> Result<Bitmap, Error> {
438438
option_to_not_found(
439-
self.db
440-
.get_with(&to_key(BLOCK_INPUT_BITMAP_PREFIX, bh), Bitmap::deserialize),
439+
self.db.get_with(
440+
&to_key(BLOCK_INPUT_BITMAP_PREFIX, bh),
441+
Bitmap::deserialize::<Portable>,
442+
),
441443
|| "legacy block input bitmap".to_string(),
442444
)
443445
}

chain/src/txhashset/bitmap_accumulator.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ impl BitmapAccumulator {
148148
let mut pmmr = PMMR::at(&mut self.backend, last_pos);
149149
let chunk_pos = pmmr::insertion_to_pmmr_index(chunk_idx + 1);
150150
let rewind_pos = chunk_pos.saturating_sub(1);
151-
pmmr.rewind(rewind_pos, &Bitmap::create())
151+
pmmr.rewind(rewind_pos, &Bitmap::new())
152152
.map_err(|e| ErrorKind::Other(format!("pmmr rewind error, {}", e)))?;
153153
Ok(())
154154
}

chain/src/txhashset/txhashset.rs

+16-18
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ pub struct PMMRHandle<T: PMMRable> {
5656
}
5757

5858
impl<T: PMMRable> PMMRHandle<T> {
59-
/// Constructor to create a PMMR handle from an existing directory structure on disk.
60-
/// Creates the backend files as necessary if they do not already exist.
59+
/// Constructor to new a PMMR handle from an existing directory structure on disk.
60+
/// news the backend files as necessary if they do not already exist.
6161
pub fn new<P: AsRef<Path>>(
6262
path: P,
6363
prunable: bool,
@@ -655,7 +655,7 @@ where
655655
let rproof_pmmr =
656656
ReadonlyPMMR::at(&trees.rproof_pmmr_h.backend, trees.rproof_pmmr_h.last_pos);
657657

658-
// Create a new batch here to pass into the utxo_view.
658+
// new a new batch here to pass into the utxo_view.
659659
// Discard it (rollback) after we finish with the utxo_view.
660660
let batch = trees.commit_index.batch()?;
661661
let utxo = UTXOView::new(header_pmmr, output_pmmr, rproof_pmmr);
@@ -667,7 +667,7 @@ where
667667
/// Rewindable (but still readonly) view on the kernel MMR.
668668
/// The underlying backend is readonly. But we permit the PMMR to be "rewound"
669669
/// via last_pos.
670-
/// We create a new db batch for this view and discard it (rollback)
670+
/// We new a new db batch for this view and discard it (rollback)
671671
/// when we are done with the view.
672672
pub fn rewindable_kernel_view<F, T>(trees: &TxHashSet, inner: F) -> Result<T, Error>
673673
where
@@ -678,7 +678,7 @@ where
678678
let kernel_pmmr =
679679
RewindablePMMR::at(&trees.kernel_pmmr_h.backend, trees.kernel_pmmr_h.last_pos);
680680

681-
// Create a new batch here to pass into the kernel_view.
681+
// new a new batch here to pass into the kernel_view.
682682
// Discard it (rollback) after we finish with the kernel_view.
683683
let batch = trees.commit_index.batch()?;
684684
let header = batch.head_header()?;
@@ -712,7 +712,7 @@ where
712712
let head = batch.head()?;
713713
let header_head = batch.header_head()?;
714714

715-
// create a child transaction so if the state is rolled back by itself, all
715+
// new a child transaction so if the state is rolled back by itself, all
716716
// index saving can be undone
717717
let child_batch = batch.child()?;
718718
{
@@ -817,7 +817,7 @@ where
817817
let res: Result<T, Error>;
818818
let rollback: bool;
819819

820-
// create a child transaction so if the state is rolled back by itself, all
820+
// new a child transaction so if the state is rolled back by itself, all
821821
// index saving can be undone
822822
let child_batch = batch.child()?;
823823

@@ -961,11 +961,9 @@ impl<'a> HeaderExtension<'a> {
961961
);
962962

963963
let header_pos = pmmr::insertion_to_pmmr_index(header.height + 1);
964-
self.pmmr
965-
.rewind(header_pos, &Bitmap::create())
966-
.map_err(|e| {
967-
ErrorKind::TxHashSetErr(format!("pmmr rewind for pos {}, {}", header_pos, e))
968-
})?;
964+
self.pmmr.rewind(header_pos, &Bitmap::new()).map_err(|e| {
965+
ErrorKind::TxHashSetErr(format!("pmmr rewind for pos {}, {}", header_pos, e))
966+
})?;
969967

970968
// Update our head to reflect the header we rewound to.
971969
self.head = Tip::from_header(header);
@@ -1146,7 +1144,7 @@ impl<'a> Extension<'a> {
11461144
// Note: This validates and NRD relative height locks via the "recent" kernel index.
11471145
self.apply_kernels(b.kernels(), b.header.height, batch)?;
11481146

1149-
// Update our BitmapAccumulator based on affected outputs (both spent and created).
1147+
// Update our BitmapAccumulator based on affected outputs (both spent and newd).
11501148
self.apply_to_bitmap_accumulator(&affected_pos)?;
11511149

11521150
// Update the head of the extension to reflect the block we just applied.
@@ -1368,7 +1366,7 @@ impl<'a> Extension<'a> {
13681366
let mut affected_pos = spent_pos;
13691367
affected_pos.push(self.output_pmmr.last_pos);
13701368

1371-
// Remove any entries from the output_pos created by the block being rewound.
1369+
// Remove any entries from the output_pos newd by the block being rewound.
13721370
let mut missing_count = 0;
13731371
for out in block.outputs() {
13741372
if batch.delete_output_pos_height(&out.commitment()).is_err() {
@@ -1426,7 +1424,7 @@ impl<'a> Extension<'a> {
14261424
.rewind(output_pos, &bitmap)
14271425
.map_err(|e| ErrorKind::TxHashSetErr(format!("rproof_pmmr rewind error, {}", e)))?;
14281426
self.kernel_pmmr
1429-
.rewind(kernel_pos, &Bitmap::create())
1427+
.rewind(kernel_pos, &Bitmap::new())
14301428
.map_err(|e| ErrorKind::TxHashSetErr(format!("kernel_pmmr rewind error, {}", e)))?;
14311429
Ok(())
14321430
}
@@ -1741,7 +1739,7 @@ pub fn zip_read(root_dir: String, header: &BlockHeader) -> Result<File, Error> {
17411739
}
17421740
}
17431741

1744-
// otherwise, create the zip archive
1742+
// otherwise, new the zip archive
17451743
let path_to_be_cleanup = {
17461744
// Temp txhashset directory
17471745
let temp_txhashset_path = Path::new(&root_dir).join(format!(
@@ -1767,7 +1765,7 @@ pub fn zip_read(root_dir: String, header: &BlockHeader) -> Result<File, Error> {
17671765
};
17681766

17691767
debug!(
1770-
"zip_read: {} at {}: created zip file: {:?}",
1768+
"zip_read: {} at {}: newd zip file: {:?}",
17711769
header.hash(),
17721770
header.height,
17731771
zip_path
@@ -1872,7 +1870,7 @@ fn input_pos_to_rewind(
18721870
head_header: &BlockHeader,
18731871
batch: &Batch<'_>,
18741872
) -> Result<Bitmap, Error> {
1875-
let mut bitmap = Bitmap::create();
1873+
let mut bitmap = Bitmap::new();
18761874
let mut current = head_header.clone();
18771875
while current.height > block_header.height {
18781876
if let Ok(block_bitmap) = batch.get_block_input_bitmap(&current.hash()) {

core/Cargo.toml

+1-1
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.5.2"
15+
croaring = "1.0.1"
1616
enum_primitive = "0.1"
1717
failure = "0.1"
1818
failure_derive = "0.1"

0 commit comments

Comments
 (0)