add stake lockup (#5782)

* add stake lockup

* fixup
This commit is contained in:
Rob Walker
2019-09-04 13:34:09 -07:00
committed by GitHub
parent 94eb78d399
commit 933e835838
7 changed files with 203 additions and 50 deletions

View File

@ -1,5 +1,4 @@
use crate::pubkey::Pubkey;
use crate::Epoch;
use crate::{pubkey::Pubkey, timing::Epoch};
use std::{cmp, fmt};
/// An Account with data that is stored on chain
@ -64,6 +63,19 @@ impl Account {
})
}
pub fn new_data_with_space<T: serde::Serialize>(
lamports: u64,
state: &T,
space: usize,
owner: &Pubkey,
) -> Result<Account, bincode::Error> {
let mut account = Self::new(lamports, space, owner);
account.serialize_data(state)?;
Ok(account)
}
pub fn deserialize_data<T: serde::de::DeserializeOwned>(&self) -> Result<T, bincode::Error> {
bincode::deserialize(&self.data)
}

View File

@ -28,6 +28,3 @@ pub mod transport;
#[macro_use]
extern crate serde_derive;
pub type Epoch = u64;
pub type Slot = u64;