Skip to content

Commit

Permalink
chore: create new enr if diff ip addr
Browse files Browse the repository at this point in the history
  • Loading branch information
Vid201 committed Oct 6, 2024
1 parent 1235d01 commit 9252858
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions crates/p2p/src/service/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,15 +151,13 @@ impl Network {
let combined_key = keypair_to_combined(&key).expect("keypair to combined key failed");

// Handle ENR
let enr = if let Some(enr) = load_enr_from_file(&config.node_enr_file) {
enr
} else {
let enr = build_enr(&combined_key, &config).expect("enr building failed");

save_enr_to_file(&enr, &config.node_enr_file);

enr
};
let enr = load_enr_from_file(&config.node_enr_file)
.filter(|enr| enr.ip4() == config.ipv4_addr)
.unwrap_or_else(|| {
let enr = build_enr(&combined_key, &config).expect("enr building failed");
save_enr_to_file(&enr, &config.node_enr_file);
enr
});

info!("Enr: {}", enr);

Expand Down

0 comments on commit 9252858

Please sign in to comment.