check serum OO headers in ScanningAccountRetriever
This commit is contained in:
parent
b19678f874
commit
ab9d3c37b4
|
@ -379,7 +379,10 @@ impl<'a, 'info> ScanningAccountRetriever<'a, 'info> {
|
|||
let serum3_start = perp_oracles_start + n_perps;
|
||||
let n_serum3 = ais[serum3_start..]
|
||||
.iter()
|
||||
.filter(|x| x.data_len() == std::mem::size_of::<serum_dex::state::OpenOrders>() + 12)
|
||||
.take_while(|x| {
|
||||
x.data_len() == std::mem::size_of::<serum_dex::state::OpenOrders>() + 12
|
||||
&& serum3_cpi::has_serum_header(&x.data.borrow())
|
||||
})
|
||||
.count();
|
||||
let fallback_oracles_start = serum3_start + n_serum3;
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use anchor_lang::prelude::*;
|
||||
use serum_dex::state::{OpenOrders, ToAlignedBytes};
|
||||
use serum_dex::state::{OpenOrders, ToAlignedBytes, ACCOUNT_HEAD_PADDING};
|
||||
|
||||
use std::cell::{Ref, RefMut};
|
||||
use std::cmp::min;
|
||||
|
@ -49,6 +49,14 @@ fn strip_data_header_mut<H: bytemuck::Pod, D: bytemuck::Pod>(
|
|||
}))
|
||||
}
|
||||
|
||||
pub fn has_serum_header(data: &[u8]) -> bool {
|
||||
if data.len() < 5 {
|
||||
return false;
|
||||
}
|
||||
let head = &data[..5];
|
||||
head == ACCOUNT_HEAD_PADDING
|
||||
}
|
||||
|
||||
pub fn load_market_state<'a>(
|
||||
market_account: &'a AccountInfo,
|
||||
program_id: &Pubkey,
|
||||
|
|
Loading…
Reference in New Issue