feat: make load_network_config and lookup_head generic over DB (#5692)

Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
This commit is contained in:
Dan Cline
2023-12-05 15:48:09 -05:00
committed by GitHub
parent 926766d482
commit 227e1b7ad5

View File

@@ -744,7 +744,7 @@ impl<Ext: RethCliExt> NodeCommand<Ext> {
/// Fetches the head block from the database.
///
/// If the database is empty, returns the genesis block.
fn lookup_head(&self, db: Arc<DatabaseEnv>) -> RethResult<Head> {
fn lookup_head<DB: Database>(&self, db: DB) -> RethResult<Head> {
let factory = ProviderFactory::new(db, self.chain.clone());
let provider = factory.provider()?;
@@ -826,15 +826,15 @@ impl<Ext: RethCliExt> NodeCommand<Ext> {
}
}
fn load_network_config(
fn load_network_config<DB: Database>(
&self,
config: &Config,
db: Arc<DatabaseEnv>,
db: DB,
executor: TaskExecutor,
head: Head,
secret_key: SecretKey,
default_peers_path: PathBuf,
) -> NetworkConfig<ProviderFactory<Arc<DatabaseEnv>>> {
) -> NetworkConfig<ProviderFactory<DB>> {
let cfg_builder = self
.network
.network_config(config, self.chain.clone(), secret_key, default_peers_path)