Skip to content

Commit b538d5b

Browse files
committed
fix: remove initPriceFeedIndex instr to reduce binary size
1 parent 632208e commit b538d5b

File tree

3 files changed

+9
-127
lines changed

3 files changed

+9
-127
lines changed

program/rust/src/processor.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ mod del_product;
3232
mod del_publisher;
3333
mod init_mapping;
3434
mod init_price;
35-
mod init_price_feed_index;
3635
mod resize_mapping;
3736
mod set_max_latency;
3837
mod set_min_pub;
@@ -67,15 +66,13 @@ pub use {
6766
},
6867
upd_product::upd_product,
6968
};
70-
use {
71-
init_price_feed_index::init_price_feed_index,
72-
solana_program::{
73-
program_error::ProgramError,
74-
rent::Rent,
75-
sysvar::Sysvar,
76-
},
69+
use solana_program::{
70+
program_error::ProgramError,
71+
rent::Rent,
72+
sysvar::Sysvar,
7773
};
7874

75+
7976
/// Dispatch to the right instruction in the oracle.
8077
pub fn process_instruction(
8178
program_id: &Pubkey,
@@ -107,7 +104,10 @@ pub fn process_instruction(
107104
DelProduct => del_product(program_id, accounts, instruction_data),
108105
UpdPermissions => upd_permissions(program_id, accounts, instruction_data),
109106
SetMaxLatency => set_max_latency(program_id, accounts, instruction_data),
110-
InitPriceFeedIndex => init_price_feed_index(program_id, accounts, instruction_data),
107+
InitPriceFeedIndex => {
108+
solana_program::msg!("Oracle init price feed index instruction has been removed. Bailing out!");
109+
Err(OracleError::UnrecognizedInstruction.into())
110+
}
111111
ResizeMapping => resize_mapping(program_id, accounts, instruction_data),
112112
}
113113
}

program/rust/src/processor/init_price_feed_index.rs

Lines changed: 0 additions & 66 deletions
This file was deleted.

program/rust/src/tests/test_add_price.rs

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -130,58 +130,6 @@ fn test_add_price() {
130130
assert!(product_data.first_price_account == *price_account_2.key);
131131
}
132132

133-
// Emulate pre-existing price accounts without a feed index.
134-
{
135-
let mut price_data = load_checked::<PriceAccount>(&price_account, PC_VERSION).unwrap();
136-
price_data.feed_index = 0;
137-
let mut price_data_2 = load_checked::<PriceAccount>(&price_account_2, PC_VERSION).unwrap();
138-
price_data_2.feed_index = 0;
139-
}
140-
let hdr_init_price_feed_index = CommandHeader::from(OracleCommand::InitPriceFeedIndex);
141-
let instruction_data_init_price_feed_index = bytes_of(&hdr_init_price_feed_index);
142-
process_instruction(
143-
&program_id,
144-
&[
145-
funding_account.clone(),
146-
price_account.clone(),
147-
permissions_account.clone(),
148-
],
149-
instruction_data_init_price_feed_index,
150-
)
151-
.unwrap();
152-
{
153-
let price_data = load_checked::<PriceAccount>(&price_account, PC_VERSION).unwrap();
154-
assert_eq!(price_data.feed_index, 3);
155-
}
156-
process_instruction(
157-
&program_id,
158-
&[
159-
funding_account.clone(),
160-
price_account_2.clone(),
161-
permissions_account.clone(),
162-
],
163-
instruction_data_init_price_feed_index,
164-
)
165-
.unwrap();
166-
{
167-
let price_data_2 = load_checked::<PriceAccount>(&price_account_2, PC_VERSION).unwrap();
168-
assert_eq!(price_data_2.feed_index, 4);
169-
}
170-
171-
// Feed index is already set.
172-
assert_eq!(
173-
process_instruction(
174-
&program_id,
175-
&[
176-
funding_account.clone(),
177-
price_account_2.clone(),
178-
permissions_account.clone(),
179-
],
180-
instruction_data_init_price_feed_index,
181-
),
182-
Err(OracleError::FeedIndexAlreadyInitialized.into())
183-
);
184-
185133
// Wrong number of accounts
186134
assert_eq!(
187135
process_instruction(

0 commit comments

Comments
 (0)