Fix buffer index in compact

Indexes used to be positions in the full file, not in the
intermediary buffer.
This commit is contained in:
Ignotus Peverell 2018-04-02 21:49:35 +01:00
parent 959b1d3e8d
commit eefb4319f8
No known key found for this signature in database
GPG key ID: 99CD25F39F8F8211
4 changed files with 13 additions and 18 deletions

6
Cargo.lock generated
View file

@ -384,7 +384,7 @@ dependencies = [
[[package]]
name = "cuckoo_miner"
version = "0.1.0"
source = "git+https://github.com/mimblewimble/cuckoo-miner?tag=grin_integration_24#d017db6d70061f566a65f35513dc0252bb5b4ee1"
source = "git+https://github.com/mimblewimble/cuckoo-miner?tag=grin_integration_25#40cb3146a56d338452b350bbfab18bf0805d1d9d"
dependencies = [
"blake2-rfc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)",
"byteorder 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)",
@ -772,7 +772,7 @@ name = "grin_pow"
version = "0.2.0"
dependencies = [
"blake2-rfc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)",
"cuckoo_miner 0.1.0 (git+https://github.com/mimblewimble/cuckoo-miner?tag=grin_integration_24)",
"cuckoo_miner 0.1.0 (git+https://github.com/mimblewimble/cuckoo-miner?tag=grin_integration_25)",
"grin_core 0.2.0",
"grin_util 0.2.0",
"lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
@ -2281,7 +2281,7 @@ dependencies = [
"checksum crossbeam-utils 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2760899e32a1d58d5abb31129f8fae5de75220bc2176e77ff7c627ae45c918d9"
"checksum crossbeam-utils 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d636a8b3bcc1b409d7ffd3facef8f21dcb4009626adbd0c5e6c4305c07253c7b"
"checksum csv 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7ef22b37c7a51c564a365892c012dc0271221fdcc64c69b19ba4d6fa8bd96d9c"
"checksum cuckoo_miner 0.1.0 (git+https://github.com/mimblewimble/cuckoo-miner?tag=grin_integration_24)" = "<none>"
"checksum cuckoo_miner 0.1.0 (git+https://github.com/mimblewimble/cuckoo-miner?tag=grin_integration_25)" = "<none>"
"checksum cursive 0.8.2-alpha.0 (git+https://github.com/yeastplume/Cursive?tag=grin_integration_1)" = "<none>"
"checksum daemonize 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "0239832c1b4ca406d5ec73728cf4c7336d25cf85dd32db9e047e9e706ee0e935"
"checksum dtoa 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "0dd841b58510c9618291ffa448da2e4e0f699d984d436122372f446dae62263d"

View file

@ -22,6 +22,7 @@
extern crate byteorder;
extern crate env_logger;
#[macro_use]
extern crate grin_core as core;
extern crate grin_util as util;
extern crate libc;

View file

@ -368,13 +368,10 @@ where
{
let record_len = 32;
let off_to_rm = pos_to_rm
.iter()
.map(|&pos| {
let shift = self.pruned_nodes.get_shift(pos);
(pos - 1 - shift.unwrap()) * record_len
})
.collect();
let off_to_rm = map_vec!(pos_to_rm, |&pos| {
let shift = self.pruned_nodes.get_shift(pos).unwrap();
(pos - 1 - shift) * record_len
});
self.hash_file.save_prune(
tmp_prune_file_hash.clone(),
@ -388,13 +385,10 @@ where
{
let record_len = T::len() as u64;
let off_to_rm = leaf_pos_to_rm
.iter()
.map(|pos| {
let shift = self.pruned_nodes.get_leaf_shift(*pos);
(pmmr::n_leaves(pos - shift.unwrap()) - 1) * record_len
})
.collect::<Vec<_>>();
let off_to_rm = map_vec!(leaf_pos_to_rm, |pos| {
let shift = self.pruned_nodes.get_leaf_shift(*pos);
(pmmr::n_leaves(pos - shift.unwrap()) - 1) * record_len
});
self.data_file.save_prune(
tmp_prune_file_data.clone(),

View file

@ -187,7 +187,7 @@ impl AppendOnlyFile {
// in which case we skip
let mut buf_start = 0;
while prune_offs[prune_pos] >= read && prune_offs[prune_pos] < read + len {
let prune_at = prune_offs[prune_pos] as usize;
let prune_at = (prune_offs[prune_pos] - read) as usize;
if prune_at != buf_start {
writer.write_all(&buf[buf_start..prune_at])?;
} else {