Skip to content

Commit ea3bef2

Browse files
committed
program: drop ConfigKeys::serialized_size
1 parent d5398e7 commit ea3bef2

File tree

3 files changed

+3
-11
lines changed

3 files changed

+3
-11
lines changed

program/benches/setup.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ pub trait BenchSetup: ConfigState + Default {
3939

4040
fn default_space(keys: Vec<(Pubkey, bool)>) -> usize {
4141
(Self::max_space()
42-
.checked_add(ConfigKeys::serialized_size(keys))
42+
.checked_add(bincode::serialized_size(&ConfigKeys { keys }).unwrap())
4343
.unwrap()) as usize
4444
}
4545

program/src/instruction.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use {
55
id,
66
state::{ConfigKeys, ConfigState},
77
},
8+
bincode::serialized_size,
89
solana_program::{
910
instruction::{AccountMeta, Instruction},
1011
pubkey::Pubkey,
@@ -25,7 +26,7 @@ pub fn create_account<T: ConfigState>(
2526
lamports: u64,
2627
keys: Vec<(Pubkey, bool)>,
2728
) -> Vec<Instruction> {
28-
let space = T::max_space().saturating_add(ConfigKeys::serialized_size(keys));
29+
let space = T::max_space().saturating_add(serialized_size(&ConfigKeys { keys }).unwrap());
2930
vec![
3031
system_instruction::create_account(
3132
from_account_pubkey,

program/src/state.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
//! Program state types.
22
33
use {
4-
bincode::serialized_size,
54
serde::{Deserialize, Serialize},
65
solana_program::{pubkey::Pubkey, short_vec},
76
};
@@ -20,11 +19,3 @@ pub struct ConfigKeys {
2019
#[serde(with = "short_vec")]
2120
pub keys: Vec<(Pubkey, bool)>,
2221
}
23-
24-
impl ConfigKeys {
25-
/// Get the serialized size of the `ConfigKeys` struct,
26-
/// given a list of keys.
27-
pub fn serialized_size(keys: Vec<(Pubkey, bool)>) -> u64 {
28-
serialized_size(&ConfigKeys { keys }).unwrap()
29-
}
30-
}

0 commit comments

Comments
 (0)