Use serde-bytes to serialize u8 efficiently (#6442)

automerge
This commit is contained in:
Jack May
2019-10-18 17:18:06 -07:00
committed by Grimes
parent 621c67a8cb
commit 985f5c7351
7 changed files with 35 additions and 7 deletions

View File

@ -9,6 +9,7 @@ pub struct Account {
/// lamports in the account
pub lamports: u64,
/// data held in this account
#[serde(with = "serde_bytes")]
pub data: Vec<u8>,
/// the program that owns this account. If executable, the program that loads this account.
pub owner: Pubkey,
@ -18,7 +19,7 @@ pub struct Account {
pub rent_epoch: Epoch,
/// Hash of this account's state, skip serializing as to not expose to external api
/// Used for keeping the accounts state hash updated.
#[serde(skip_serializing, skip_deserializing)]
#[serde(skip)]
pub hash: Hash,
}

View File

@ -9,7 +9,11 @@ pub enum LoaderInstruction {
/// * key[0] - the account to write into.
///
/// The transaction must be signed by key[0]
Write { offset: u32, bytes: Vec<u8> },
Write {
offset: u32,
#[serde(with = "serde_bytes")]
bytes: Vec<u8>,
},
/// Finalize an account loaded with program data for execution.
/// The exact preparation steps is loader specific but on success the loader must set the executable
@ -24,7 +28,10 @@ pub enum LoaderInstruction {
/// Invoke the "main" entrypoint with the given data.
///
/// * key[0] - an executable account
InvokeMain { data: Vec<u8> },
InvokeMain {
#[serde(with = "serde_bytes")]
data: Vec<u8>,
},
}
pub fn write(