mirror of
https://github.com/urbit/ares.git
synced 2024-11-22 06:32:47 +03:00
cargo: clippy
This commit is contained in:
parent
14d8c138d7
commit
da1cf12ff0
@ -8,7 +8,7 @@ use lmdb::{Cursor, Environment, EnvironmentFlags, Error as LmdbError, Transactio
|
||||
use lmdb_sys as ffi;
|
||||
use std::convert::TryInto;
|
||||
use std::fs;
|
||||
use std::path::PathBuf;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::result::Result as StdResult;
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
@ -48,8 +48,8 @@ impl Disk {
|
||||
let (_, high) = lmdb_gulf(&env);
|
||||
Disk {
|
||||
dir: log_dir,
|
||||
epoch: epoch,
|
||||
env: env,
|
||||
epoch,
|
||||
env,
|
||||
done: high,
|
||||
}
|
||||
}
|
||||
@ -57,7 +57,7 @@ impl Disk {
|
||||
|
||||
/// Get the number of the latest epoch in the given directory, or return
|
||||
/// an error if there are no epochs or the path specified isn't a directory.
|
||||
pub fn epoch_last(log_dir: &PathBuf) -> Result<u64> {
|
||||
pub fn epoch_last(log_dir: &Path) -> Result<u64> {
|
||||
if !log_dir.is_dir() {
|
||||
return Err(Error::InvalidPath);
|
||||
}
|
||||
@ -65,9 +65,8 @@ pub fn epoch_last(log_dir: &PathBuf) -> Result<u64> {
|
||||
let mut some = false;
|
||||
let mut last = 0;
|
||||
|
||||
if let Ok(entries) = fs::read_dir(log_dir.clone()) {
|
||||
for entry in entries {
|
||||
if let Ok(entry) = entry {
|
||||
if let Ok(entries) = fs::read_dir(log_dir) {
|
||||
for entry in entries.flatten() {
|
||||
if let Some(name) = entry.file_name().to_str() {
|
||||
if let Some(epoch) = name.strip_prefix("0i") {
|
||||
if let Ok(n) = epoch.parse::<u64>() {
|
||||
@ -80,7 +79,6 @@ pub fn epoch_last(log_dir: &PathBuf) -> Result<u64> {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if some {
|
||||
return Ok(last);
|
||||
@ -91,7 +89,7 @@ pub fn epoch_last(log_dir: &PathBuf) -> Result<u64> {
|
||||
|
||||
/// Read a value from the metadata database.
|
||||
pub fn disk_read_meta(env: &Environment, key: &str) -> Result<u64> {
|
||||
lmdb_read_meta(env, key).map_err(|e| Error::Lmdb(e))
|
||||
lmdb_read_meta(env, key).map_err(Error::Lmdb)
|
||||
}
|
||||
|
||||
/// Read a single event `eve` from the database.
|
||||
|
@ -28,7 +28,7 @@ pub fn lmdb_gulf(env: &Environment) -> (u64, u64) {
|
||||
let low = u64::from_le_bytes(first.try_into().unwrap());
|
||||
if let Some(last) = cursor.get(None, None, ffi::MDB_LAST).unwrap().0 {
|
||||
let high = u64::from_le_bytes(last.try_into().unwrap());
|
||||
return (low, high);
|
||||
(low, high)
|
||||
} else {
|
||||
panic!("Couldn't get last event from the database");
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
use ares::jets::hot::URBIT_HOT_STATE;
|
||||
use ares::mars::{mars_play, Mars};
|
||||
use ares::serf::{Context, serf};
|
||||
use ares::serf::{serf, Context};
|
||||
use ares::trace::{create_trace_file, write_metadata};
|
||||
use std::env;
|
||||
use std::io;
|
||||
|
@ -1,12 +1,12 @@
|
||||
use std::{cmp::min, path::PathBuf};
|
||||
use std::fmt::{Display, Formatter, Result as FmtResult};
|
||||
use std::result::Result as StdResult;
|
||||
use std::{cmp::min, path::PathBuf};
|
||||
|
||||
use crate::disk::*;
|
||||
use crate::hamt::Hamt;
|
||||
use crate::jets::list::util::lent;
|
||||
use crate::lmdb::lmdb_gulf;
|
||||
use crate::noun::{D, Noun};
|
||||
use crate::noun::{Noun, D};
|
||||
use crate::persist::pma_close;
|
||||
use crate::serf::{clear_interrupt, play_life, work, Context};
|
||||
|
||||
@ -45,7 +45,6 @@ pub struct Mars {
|
||||
|
||||
/// Last event processed.
|
||||
pub done: u64,
|
||||
|
||||
}
|
||||
|
||||
/// Do a boot.
|
||||
@ -68,7 +67,10 @@ pub fn mars_play(mut mars: Mars, mut eve: u64, _sap: u64) -> u64 {
|
||||
eve = mars.ctx.log.done;
|
||||
} else if eve <= mars.ctx.log.done {
|
||||
eprintln!("mars: already computed {}\r", eve);
|
||||
eprintln!(" state={}, &mut mars.log={}\r", mars.done, mars.ctx.log.done);
|
||||
eprintln!(
|
||||
" state={}, &mut mars.log={}\r",
|
||||
mars.done, mars.ctx.log.done
|
||||
);
|
||||
return played;
|
||||
} else {
|
||||
eve = min(eve, mars.ctx.log.done);
|
||||
@ -96,7 +98,12 @@ pub fn mars_play(mut mars: Mars, mut eve: u64, _sap: u64) -> u64 {
|
||||
if (eve + 1) == mars.ctx.log.done {
|
||||
eprintln!("play: event {}\r", mars.ctx.log.done);
|
||||
} else if eve != mars.ctx.log.done {
|
||||
eprintln!("play: events {}-{} of {}\r", (mars.done + 1), eve, mars.ctx.log.done);
|
||||
eprintln!(
|
||||
"play: events {}-{} of {}\r",
|
||||
(mars.done + 1),
|
||||
eve,
|
||||
mars.ctx.log.done
|
||||
);
|
||||
} else {
|
||||
eprintln!("play: events {}-{}\r", (mars.done + 1), eve);
|
||||
}
|
||||
|
@ -187,7 +187,7 @@ impl Context {
|
||||
arvo,
|
||||
mug,
|
||||
nock_context,
|
||||
log
|
||||
log,
|
||||
}
|
||||
}
|
||||
|
||||
@ -319,7 +319,7 @@ pub fn serf(constant_hot_state: &[HotEntry]) -> io::Result<()> {
|
||||
.ok_or(io::Error::new(io::ErrorKind::Other, "no pier path"))?;
|
||||
let pier_path = PathBuf::from(pier_path_string);
|
||||
let snap_path = pier_path.join(".urb/chk");
|
||||
create_dir_all(&snap_path)?;
|
||||
create_dir_all(snap_path)?;
|
||||
|
||||
let wag: u32 = std::env::args()
|
||||
.nth(4)
|
||||
|
Loading…
Reference in New Issue
Block a user