Fix with platform specific import. Add store crate to CI

This commit is contained in:
Ignotus Peverell 2017-09-29 18:09:44 +00:00
parent 07bf22c881
commit 0a57258d42
No known key found for this signature in database
GPG key ID: 99CD25F39F8F8211
5 changed files with 36 additions and 31 deletions
.travis.yml
chain/src
core/src/core
store

View file

@ -18,6 +18,7 @@ env:
- RUST_BACKTRACE="1"
matrix:
- TEST_DIR=core
- TEST_DIR=store
- TEST_DIR=chain
- TEST_DIR=p2p
- TEST_DIR=api

View file

@ -257,27 +257,7 @@ impl<'a> Extension<'a> {
// Sizes of the sum trees, used by `extending` on rollback.
fn sizes(&self) -> (u64, u64, u64) {
(self.output_pmmr.unpruned_size(), self.rproof_pmmr.unpruned_size(), self.kernel_pmmr.unpruned_size())
}
/// Debugging utility to print information about the MMRs.
pub fn dump(&self) {
let sz = self.output_pmmr.unpruned_size();
if sz > 25 {
return;
}
println!("UXTO set, size: {}", sz);
for n in 0..sz {
print!("{:>8} ", n + 1);
}
println!("");
for n in 1..(sz+1) {
let ohs = self.output_pmmr.get(n);
match ohs {
Some(hs) => print!("{} ", hs.hash),
None => print!("??"),
}
}
println!("");
(self.output_pmmr.unpruned_size(), self.rproof_pmmr.unpruned_size(),
self.kernel_pmmr.unpruned_size())
}
}

View file

@ -318,6 +318,27 @@ impl<'a, T, B> PMMR<'a, T, B> where T: Summable + Hashed + Clone, B: 'a + Backen
pub fn unpruned_size(&self) -> u64 {
self.last_pos
}
/// Debugging utility to print information about the MMRs.
pub fn dump(&self) {
let sz = self.unpruned_size();
if sz > 25 {
return;
}
println!("UXTO set, size: {}", sz);
for n in 0..sz {
print!("{:>8} ", n + 1);
}
println!("");
for n in 1..(sz+1) {
let ohs = self.get(n);
match ohs {
Some(hs) => print!("{} ", hs.hash),
None => print!("{:>8} ", "??"),
}
}
println!("");
}
}
/// Simple MMR backend implementation based on a Vector. Pruning does not

View file

@ -22,7 +22,10 @@ use std::os::unix::io::AsRawFd;
use std::path::Path;
use std::io::Read;
use libc;
#[cfg(any(target_os = "linux"))]
use libc::{off64_t, ftruncate64};
#[cfg(not(any(target_os = "linux", target_os = "android")))]
use libc::{off_t as off64_t, ftruncate as ftruncate64};
use core::core::pmmr::{self, Summable, Backend, HashSum, VecBackend};
use core::ser;
@ -138,7 +141,7 @@ impl AppendOnlyFile {
/// Truncates the underlying file to the provided offset
fn truncate(&self, offs: u64) -> io::Result<()> {
let fd = self.file.as_raw_fd();
let res = unsafe { libc::ftruncate64(fd, offs as i64) };
let res = unsafe { ftruncate64(fd, offs as off64_t) };
if res == -1 {
Err(io::Error::last_os_error())
} else {
@ -239,7 +242,7 @@ impl RemoveLog {
fn include_tuple(v: &Vec<(u64, u32)>, e: u64) -> bool {
if let Err(pos) = v.binary_search(&(e, 0)) {
if pos > 0 && v[pos-1].0 == e {
if pos < v.len() && v[pos].0 == e {
return true;
}
}

View file

@ -80,9 +80,9 @@ fn sumtree_prune_compact() {
// pruning some choice nodes
{
let mut pmmr = PMMR::at(&mut backend, mmr_size);
pmmr.prune(1).unwrap();
pmmr.prune(4).unwrap();
pmmr.prune(5).unwrap();
pmmr.prune(1, 1).unwrap();
pmmr.prune(4, 1).unwrap();
pmmr.prune(5, 1).unwrap();
}
backend.sync().unwrap();
@ -118,8 +118,8 @@ fn sumtree_reload() {
{
let mut pmmr = PMMR::at(&mut backend, mmr_size);
root = pmmr.root();
pmmr.prune(1).unwrap();
pmmr.prune(4).unwrap();
pmmr.prune(1, 1).unwrap();
pmmr.prune(4, 1).unwrap();
}
backend.sync().unwrap();
backend.check_compact(1).unwrap();
@ -128,7 +128,7 @@ fn sumtree_reload() {
// prune some more to get rm log data
{
let mut pmmr = PMMR::at(&mut backend, mmr_size);
pmmr.prune(5).unwrap();
pmmr.prune(5, 1).unwrap();
}
backend.sync().unwrap();
}