Revert "src/consensus: removed fixed genesis timestamp (if sled db doesn't exists it restarts from current timestamp)"

This reverts commit 425d339c43.
This commit is contained in:
aggstam
2022-04-17 16:50:58 +03:00
parent 425d339c43
commit 4ed5fb001b
6 changed files with 22 additions and 16 deletions

View File

@@ -311,12 +311,13 @@ impl StateInfo {
}
fn main() -> Result<()> {
let nodes = 1;
let nodes = 4;
let genesis = 1648383795;
for i in 0..nodes {
let path = format!("~/.config/darkfi/validatord_db_{:?}", i);
let database_path = expand_path(&path).unwrap();
println!("Export data from sled database: {:?}", database_path);
let state = ValidatorState::new(database_path, i).unwrap();
let state = ValidatorState::new(database_path, i, genesis).unwrap();
let info = StateInfo::new(&*state.read().unwrap());
let info_string = format!("{:#?}", info);
let path = format!("validatord_state_{:?}", i);

View File

@@ -78,6 +78,9 @@ struct Opt {
#[structopt(long, default_value = "FOOBAR")]
/// Password for the created TLS identity
password: String,
#[structopt(long, default_value = "1648383795")]
/// Timestamp of the genesis block creation
genesis: i64,
#[structopt(long, default_value = "~/.config/darkfi/validatord_db_0")]
/// Path to the sled database folder
database: String,
@@ -195,9 +198,10 @@ async fn start(executor: Arc<Executor<'_>>, opts: &Opt) -> Result<()> {
};
// State setup
let genesis = opts.genesis;
let database_path = expand_path(&opts.database).unwrap();
let id = opts.id.clone();
let state = ValidatorState::new(database_path, id).unwrap();
let state = ValidatorState::new(database_path, id, genesis).unwrap();
// P2P registry setup
let p2p = net::P2p::new(network_settings).await;

View File

@@ -38,6 +38,9 @@ identity = "~/.config/darkfi/validatord_identity.pfx"
# Password for the created TLS identity. (Unused if serve_tls=false)
password = "FOOBAR"
# Timestamp of the genesis block creation
genesis = 1648383795
# Path to the sled database folder
database = "~/.config/darkfi/validatord_db_0"