names instead of urls

urls might have secrets in them, and we dont want those in logs
This commit is contained in:
Bryan Stitt 2022-08-24 00:32:16 +00:00
parent 59eb9a889f
commit 72312a686b
3 changed files with 12 additions and 11 deletions

@ -163,7 +163,7 @@ impl Web3Connections {
hash
} else {
// TODO: rpc name instead of url (will do this with config reload revamp)
connection_heads.remove(&rpc.url);
connection_heads.remove(&rpc.name);
// TODO: return here is wrong. synced rpcs needs an update
return Ok(());
@ -178,7 +178,7 @@ impl Web3Connections {
warn!(%rpc, ?new_block, "Block without number!");
// TODO: rpc name instead of url (will do this with config reload revamp)
connection_heads.remove(&rpc.url);
connection_heads.remove(&rpc.name);
// TODO: return here is wrong. synced rpcs needs an update
return Ok(());
@ -194,9 +194,9 @@ impl Web3Connections {
if new_block_num == U64::zero() {
warn!(%rpc, %new_block_num, "still syncing");
connection_heads.remove(&rpc.url);
connection_heads.remove(&rpc.name);
} else {
connection_heads.insert(rpc.url.clone(), new_block.clone());
connection_heads.insert(rpc.name.clone(), new_block.clone());
self.add_block(new_block.clone(), false);
}

@ -589,8 +589,8 @@ impl fmt::Debug for Web3Provider {
impl Hash for Web3Connection {
fn hash<H: Hasher>(&self, state: &mut H) {
// TODO: this is wrong. we might have two connections to the same provider
self.url.hash(state);
// TODO: is this enough?
self.name.hash(state);
}
}
@ -598,7 +598,7 @@ impl Eq for Web3Connection {}
impl Ord for Web3Connection {
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
self.url.cmp(&other.url)
self.name.cmp(&other.name)
}
}
@ -610,7 +610,7 @@ impl PartialOrd for Web3Connection {
impl PartialEq for Web3Connection {
fn eq(&self, other: &Self) -> bool {
self.url == other.url
self.name == other.name
}
}
@ -643,7 +643,7 @@ impl fmt::Debug for Web3Connection {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let mut f = f.debug_struct("Web3Connection");
f.field("url", &self.url);
f.field("name", &self.name);
let block_data_limit = self.block_data_limit.load(atomic::Ordering::Relaxed);
if block_data_limit == u64::MAX {
@ -659,6 +659,6 @@ impl fmt::Debug for Web3Connection {
impl fmt::Display for Web3Connection {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
// TODO: filter basic auth and api keys
write!(f, "{}", &self.url)
write!(f, "{}", &self.name)
}
}

@ -126,6 +126,7 @@ impl Web3Connections {
})
.collect();
// map of connection names to their connection
let mut connections = IndexMap::new();
let mut handles = vec![];
@ -134,7 +135,7 @@ impl Web3Connections {
// TODO: how should we handle errors here? one rpc being down shouldn't cause the program to exit
match x {
Ok(Ok((connection, handle))) => {
connections.insert(connection.url.clone(), connection);
connections.insert(connection.name.clone(), connection);
handles.push(handle);
}
Ok(Err(err)) => {