hide sensitive data in STDOUT

This commit is contained in:
lucretius
2024-01-29 18:07:42 +01:00
parent d3e394bffa
commit 00a1af525f
3 changed files with 17 additions and 19 deletions

View File

@@ -35,10 +35,8 @@ mod danger {
async fn get_client(uri: &http::Uri, no_cert: bool) -> Result<CompactTxStreamerClient<Channel>, Box<dyn std::error::Error>> {
let channel = if uri.scheme_str() == Some("http") {
//println!("http");
Channel::builder(uri.clone()).connect().await?
} else {
//println!("https");
let mut config = ClientConfig::new();
config.alpn_protocols.push(b"h2".to_vec());
@@ -124,7 +122,7 @@ where F : Fn(&[u8], u64) {
let mut encoded_buf = vec![];
if let Err(e) = block.encode(&mut encoded_buf) {
eprintln!("Error encoding block: {:?}", e);
error!("Error encoding block: {:?}", e);
break;
}
@@ -132,7 +130,7 @@ where F : Fn(&[u8], u64) {
}
if let Err(e) = ftx.send(Ok(())) {
eprintln!("Error sending completion signal: {:?}", e);
error!("Error sending completion signal: {:?}", e);
}
});
@@ -140,13 +138,13 @@ where F : Fn(&[u8], u64) {
while let Some(block) = response.message().await? {
if let Err(e) = tx.send(Some(block)) {
eprintln!("Error sending block to channel: {:?}", e);
error!("Error sending block to channel: {:?}", e);
break;
}
}
if let Err(e) = tx.send(None) {
eprintln!("Error sending end signal to channel: {:?}", e);
error!("Error sending end signal to channel: {:?}", e);
}
frx.iter().take(1).collect::<Result<Vec<()>, String>>()?;
@@ -191,7 +189,7 @@ where F : Fn(&[u8], u64) {
let mut client = match get_client(uri, no_cert).await {
Ok(client) => client,
Err(e) => {
eprintln!("Error creating client: {:?}", e);
error!("Error creating client: {:?}", e);
return Err(e.into());
}
};
@@ -204,7 +202,7 @@ where F : Fn(&[u8], u64) {
let maybe_response = match client.get_address_txids(request).await {
Ok(response) => response,
Err(e) => {
eprintln!("Error getting address txids: {:?}", e);
error!("Error getting address txids: {:?}", e);
return Err(e.into());
}
};
@@ -355,14 +353,14 @@ pub fn fetch_latest_block(uri: &http::Uri, no_cert: bool) -> Result<BlockId, Str
Ok(r) => r,
Err(e) => {
let errstr = format!("Error creating runtime {}", e.to_string());
eprintln!("{}", errstr);
error!("{}", errstr);
return Err(errstr);
}
};
rt.block_on(get_latest_block(uri, no_cert)).map_err(|e| {
let errstr = format!("Error getting latest block {}", e.to_string());
eprintln!("{}", errstr);
error!("{}", errstr);
errstr
})
}