Improve ergonomics of adding a new network config (#2489)

## Issue Addressed

NA

## Proposed Changes

This PR adds some more fancy macro magic to make it easier to add a new built-in (aka "baked-in") testnet config to the `lighthouse` binary.

Previously, a user needed to modify several files and repeat themselves several times. Now, they only need to add a single definition in the `eth2_config` crate. No repetition 🎉
This commit is contained in:
Paul Hauner
2021-08-30 23:27:28 +00:00
parent b4dd98b3c6
commit 1031f79aca
6 changed files with 191 additions and 66 deletions

View File

@@ -1,15 +1,9 @@
//! Extracts zipped genesis states on first run.
use eth2_config::{mainnet, prater, pyrmont, Eth2NetArchiveAndDirectory, GENESIS_FILE_NAME};
use eth2_config::{Eth2NetArchiveAndDirectory, ETH2_NET_DIRS, GENESIS_FILE_NAME};
use std::fs::File;
use std::io;
use zip::ZipArchive;
const ETH2_NET_DIRS: &[Eth2NetArchiveAndDirectory<'static>] = &[
mainnet::ETH2_NET_DIR,
pyrmont::ETH2_NET_DIR,
prater::ETH2_NET_DIR,
];
fn main() {
for network in ETH2_NET_DIRS {
match uncompress_state(network) {