Skip to content

Commit bd1f2a8

Browse files
committed
Implement fake dynamic beacon #148
1 parent 5c5d1f8 commit bd1f2a8

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

mithril-network/mithril-aggregator/src/fake_data.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
#![allow(dead_code)]
22

3+
use std::time::{SystemTime, UNIX_EPOCH};
4+
35
use crate::entities;
46

57
/// Fake Beacon
68
pub fn beacon() -> entities::Beacon {
79
let network = "testnet".to_string();
8-
let epoch = 196;
9-
let block = 3443000;
10+
let seconds_since_unix_epoch = SystemTime::now()
11+
.duration_since(UNIX_EPOCH)
12+
.unwrap()
13+
.as_secs();
14+
let epoch = seconds_since_unix_epoch / 86400_u64; // 1 epoch every day
15+
let block = 100 * (seconds_since_unix_epoch / (5 * 100)) as u64; // 1 block every 5s and 1 snapshot every 100 blocks
1016
entities::Beacon::new(network, epoch, block)
1117
}
1218

0 commit comments

Comments
 (0)