Use Serde's with attribute to shorten length encodings in Transaction

This commit is contained in:
Greg Fitzgerald
2019-03-25 09:15:16 -06:00
parent 857dc2ba47
commit c4bc710d3a
8 changed files with 323 additions and 61 deletions

View File

@@ -1,6 +1,7 @@
//! Defines a composable Instruction type and a memory-efficient CompiledInstruction.
use crate::pubkey::Pubkey;
use crate::short_vec;
use crate::system_instruction::SystemError;
use bincode::serialize;
use serde::Serialize;
@@ -92,7 +93,7 @@ impl Instruction {
}
/// Account metadata used to define Instructions
#[derive(Debug, PartialEq)]
#[derive(Debug, PartialEq, Serialize, Deserialize)]
pub struct AccountMeta {
/// An account's public key
pub pubkey: Pubkey,
@@ -112,8 +113,10 @@ pub struct CompiledInstruction {
/// Index into the transaction program ids array indicating the program account that executes this instruction
pub program_ids_index: u8,
/// Ordered indices into the transaction keys array indicating which accounts to pass to the program
#[serde(with = "short_vec")]
pub accounts: Vec<u8>,
/// The program input data
#[serde(with = "short_vec")]
pub data: Vec<u8>,
}