mirror of
https://github.com/sigp/lighthouse.git
synced 2026-04-17 21:08:32 +00:00
replace tempdir by tempfile (#2143)
## Issue Addressed Fixes #2141 Remove [tempdir](https://docs.rs/tempdir/0.3.7/tempdir/) in favor of [tempfile](https://docs.rs/tempfile/3.1.0/tempfile/). ## Proposed Changes `tempfile` has a slightly different api that makes creating temp folders with a name prefix a chore (`tempdir::TempDir::new("toto")` => `tempfile::Builder::new().prefix("toto").tempdir()`). So I removed temp folder name prefix where I deemed it not useful. Otherwise, the functionality is the same.
This commit is contained in:
@@ -13,7 +13,7 @@ use tokio::runtime::Runtime;
|
||||
use types::{ChainSpec, EnrForkId, MinimalEthSpec};
|
||||
|
||||
type E = MinimalEthSpec;
|
||||
use tempdir::TempDir;
|
||||
use tempfile::Builder as TempBuilder;
|
||||
|
||||
pub struct Libp2pInstance(LibP2PService<E>, exit_future::Signal);
|
||||
|
||||
@@ -76,7 +76,10 @@ pub fn unused_port(transport: &str) -> Result<u16, String> {
|
||||
|
||||
pub fn build_config(port: u16, mut boot_nodes: Vec<Enr>) -> NetworkConfig {
|
||||
let mut config = NetworkConfig::default();
|
||||
let path = TempDir::new(&format!("libp2p_test{}", port)).unwrap();
|
||||
let path = TempBuilder::new()
|
||||
.prefix(&format!("libp2p_test{}", port))
|
||||
.tempdir()
|
||||
.unwrap();
|
||||
|
||||
config.libp2p_port = port; // tcp port
|
||||
config.discovery_port = port; // udp port
|
||||
|
||||
Reference in New Issue
Block a user