feat: add stagekind enum and initialise syncstage table (#2426)

This commit is contained in:
Matthias Seitz
2023-04-27 14:18:10 +02:00
committed by GitHub
parent e2bacdfad7
commit d6aa7e0f91
6 changed files with 79 additions and 6 deletions

View File

@ -17,6 +17,7 @@ reth-downloaders = { path = "../../crates/net/downloaders" }
reth-primitives = { path = "../../crates/primitives" }
reth-provider = { path = "../../crates/storage/provider", features = ["test-utils"] }
reth-net-nat = { path = "../../crates/net/nat" }
reth-stages = { path = "../stages" }
# io
serde = "1.0"

View File

@ -6,6 +6,7 @@ use reth_db::{
transaction::{DbTx, DbTxMut},
};
use reth_primitives::{keccak256, Account, Bytecode, ChainSpec, StorageEntry, H256};
use reth_stages::StageKind;
use std::{path::Path, sync::Arc};
use tracing::debug;
@ -68,6 +69,11 @@ pub fn init_genesis<DB: Database>(
tx.put::<tables::HeaderTD>(0, header.difficulty.into())?;
tx.put::<tables::Headers>(0, header)?;
// insert sync stage
for stage in StageKind::ALL.iter() {
tx.put::<tables::SyncStage>(stage.to_string(), 0)?;
}
tx.commit()?;
Ok(hash)
}
@ -115,14 +121,12 @@ pub fn insert_genesis_state<DB: Database>(
#[cfg(test)]
mod tests {
use std::sync::Arc;
use super::{init_genesis, InitDatabaseError};
use reth_db::mdbx::test_utils::create_test_rw_db;
use reth_primitives::{
GOERLI, GOERLI_GENESIS, MAINNET, MAINNET_GENESIS, SEPOLIA, SEPOLIA_GENESIS,
};
use std::sync::Arc;
#[test]
fn success_init_genesis_mainnet() {