fix variable names and log to match

This commit is contained in:
Bryan Stitt 2022-09-05 15:49:53 +00:00
parent 45d51e2ac5
commit 2092e74fd3

View File

@ -272,7 +272,7 @@ impl Web3Connections {
// iterate the known heads to find the highest_work_block // iterate the known heads to find the highest_work_block
let mut checked_heads = HashSet::new(); let mut checked_heads = HashSet::new();
let mut highest_work_block: Option<ArcBlock> = None; let mut highest_work_block: Option<ArcBlock> = None;
for conn_head_hash in connection_heads.values() { for (conn_name, conn_head_hash) in connection_heads.iter() {
if checked_heads.contains(conn_head_hash) { if checked_heads.contains(conn_head_hash) {
// we already checked this head from another rpc // we already checked this head from another rpc
continue; continue;
@ -280,18 +280,17 @@ impl Web3Connections {
// don't check the same hash multiple times // don't check the same hash multiple times
checked_heads.insert(conn_head_hash); checked_heads.insert(conn_head_hash);
let rpc_head_block = if let Some(x) = self.block_hashes.get(conn_head_hash) { let conn_head_block = if let Some(x) = self.block_hashes.get(conn_head_hash) {
x x
} else { } else {
// TODO: why does this happen? // TODO: why does this happen?
warn!(%conn_head_hash, %rpc, "No block found"); warn!(%conn_head_hash, %conn_name, "No block found");
continue; continue;
}; };
match &rpc_head_block.total_difficulty { match &conn_head_block.total_difficulty {
None => { None => {
// no total difficulty. this is a bug panic!("block is missing total difficulty. this is a bug");
unimplemented!("block is missing total difficulty");
} }
Some(td) => { Some(td) => {
// if this is the first block we've tried // if this is the first block we've tried
@ -305,7 +304,7 @@ impl Web3Connections {
.as_ref() .as_ref()
.expect("there should always be total difficulty here") .expect("there should always be total difficulty here")
{ {
highest_work_block = Some(rpc_head_block); highest_work_block = Some(conn_head_block);
} }
} }
} }