Skip to content

Commit

Permalink
tuning debug routes
Browse files Browse the repository at this point in the history
  • Loading branch information
haxjump committed Nov 2, 2024
1 parent fbe58c9 commit 3f83964
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 19 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "chaindev"
version = "0.50.0"
version = "0.50.2"
edition = "2021"
authors = ["hui.fan@mail.ru"]
description = "Powerful development and testing utils for blockchain developers."
Expand All @@ -23,7 +23,7 @@ serde = { version = "1.0", features = [ "derive" ] }
serde_json = "1.0"
serde_yml = "0.0.12"

ruc = { version = "7.8.2", features = [ "cmd", "ssh" ] }
ruc = { version = "7.8.4", features = [ "cmd", "ssh" ] }
vsdb = { version = "3.0.0", default-features = false }

tendermint = { version = "0.40", optional = true }
Expand Down
8 changes: 5 additions & 3 deletions src/beacon_based/ddev/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ where
.and_then(|mut env| {
// `rev()`: migrate newer nodes(bigger id) at first
for (i, id) in nodes.iter().rev().enumerate() {
env.migrate_node(*id, host.as_ref(), *force).c(d!())?;
let new_id = env.migrate_node(*id, host.as_ref(), *force).c(d!())?;
println!(
"The {}th node has been migrated, NodeID: {id}",
"The {}th node has been migrated, previous NodeID: {id}, current NodeID: {new_id}",
1 + i
);
}
Expand Down Expand Up @@ -664,7 +664,8 @@ where
}

// Migrate the target node to another host,
// NOTE: the node ID will be reallocated
// NOTE:
// - The node ID will be reallocated and returned
fn migrate_node(
&mut self,
node_id: NodeID,
Expand Down Expand Up @@ -744,6 +745,7 @@ where
.map(|_| ())
})
.and_then(|_| self.kick_node(Some(node_id), true, force).c(d!()))
.map(|_| new_node_id)
}

// Kick out a target node, or a randomly selected one,
Expand Down
20 changes: 6 additions & 14 deletions src/common/remote.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ impl<'a> Remote<'a> {
let cmd = format!("ulimit -n 100000 >/dev/null 2>&1;{}", cmd);
self.inner
.exec_cmd(&cmd)
.map_err(|e| eg!("[{}]: {}", cmd, e))
.c(d!(cmd))
.map(|c| String::from_utf8_lossy(&c).into_owned())
}

pub fn read_file<P: AsRef<Path>>(&self, path: P) -> Result<String> {
self.inner
.read_file(path)
.map_err(|e| eg!(e))
.c(d!())
.map(|c| String::from_utf8_lossy(&c).into_owned())
}

Expand All @@ -54,9 +54,7 @@ impl<'a> Remote<'a> {
remote_path: RP,
local_path: LP,
) -> Result<()> {
self.inner
.get_file(remote_path, local_path)
.map_err(|e| eg!(e))
self.inner.get_file(remote_path, local_path).c(d!())
}

/// Return: (the local path of tgz, the name of tgz)
Expand Down Expand Up @@ -84,29 +82,23 @@ impl<'a> Remote<'a> {
remote_path: P,
contents: &[u8],
) -> Result<()> {
self.inner
.replace_file(remote_path, contents)
.map_err(|e| eg!(e))
self.inner.replace_file(remote_path, contents).c(d!())
}

pub fn append_file<P: AsRef<Path>>(
&self,
remote_path: P,
contents: &[u8],
) -> Result<()> {
self.inner
.append_file(remote_path, contents)
.map_err(|e| eg!(e))
self.inner.append_file(remote_path, contents).c(d!())
}

pub fn put_file<LP: AsRef<Path>, RP: AsRef<Path>>(
&self,
local_path: LP,
remote_path: RP,
) -> Result<()> {
self.inner
.put_file(local_path, remote_path)
.map_err(|e| eg!(e))
self.inner.put_file(local_path, remote_path).c(d!())
}

pub fn file_is_dir<P: AsRef<str>>(&self, remote_path: P) -> Result<bool> {
Expand Down

0 comments on commit 3f83964

Please sign in to comment.