Add time since genesis to sysvar::clock (#7289)

* genesis timestamp

* remove clock::create_account()

* ..

* add configure-able creation time

* dividing by 1T, should be dividing by 1B
This commit is contained in:
Rob Walker
2019-12-12 14:03:43 -08:00
committed by GitHub
parent 1b2a9270e8
commit 777ae3c215
10 changed files with 87 additions and 51 deletions

View File

@@ -2,40 +2,8 @@
//!
pub use crate::clock::Clock;
use crate::{
account::Account,
clock::{Epoch, Segment, Slot},
sysvar::Sysvar,
};
use crate::sysvar::Sysvar;
crate::declare_sysvar_id!("SysvarC1ock11111111111111111111111111111111", Clock);
impl Sysvar for Clock {}
pub fn create_account(
lamports: u64,
slot: Slot,
segment: Segment,
epoch: Epoch,
leader_schedule_epoch: Epoch,
) -> Account {
Clock {
slot,
segment,
epoch,
leader_schedule_epoch,
}
.create_account(lamports)
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_new() {
let account = create_account(1, 0, 0, 0, 0);
let clock = Clock::from_account(&account).unwrap();
assert_eq!(clock, Clock::default());
}
}