mirror of
https://github.com/0xfnzero/solana-streamer.git
synced 2026-08-05 13:27:42 +00:00
Update event_parser.rs
This commit is contained in:
@@ -388,13 +388,21 @@ impl EventParser {
|
||||
None => return Ok(()),
|
||||
};
|
||||
|
||||
// 处理 inner instructions
|
||||
// 处理 inner instructions - 查找对应的 CPI log 进行 merge
|
||||
// 当 inner_index 有值时,只查找索引大于当前 inner_index 的 CPI log
|
||||
let mut inner_instruction_event: Option<DexEvent> = None;
|
||||
if let Some(inner_instructions_ref) = inner_instructions {
|
||||
let current_inner_idx = inner_index.unwrap_or(-1) as i32;
|
||||
|
||||
// 并行执行两个任务: 解析 inner event 和提取 swap_data
|
||||
let (inner_event_result, swap_data_result) = std::thread::scope(|s| {
|
||||
let inner_event_handle = s.spawn(|| {
|
||||
for inner_instruction in inner_instructions_ref.instructions.iter() {
|
||||
for (idx, inner_instruction) in inner_instructions_ref.instructions.iter().enumerate() {
|
||||
// 只查找索引大于当前 inner_index 的 CPI log
|
||||
if (idx as i32) <= current_inner_idx {
|
||||
continue;
|
||||
}
|
||||
|
||||
let inner_data = &inner_instruction.data;
|
||||
// 检查长度(需要 16 字节的 discriminator)
|
||||
if inner_data.len() < 16 {
|
||||
@@ -420,7 +428,7 @@ impl EventParser {
|
||||
parse_swap_data_from_next_grpc_instructions(
|
||||
&event,
|
||||
inner_instructions_ref,
|
||||
inner_index.unwrap_or(-1_i64) as i8,
|
||||
current_inner_idx as i8,
|
||||
accounts,
|
||||
)
|
||||
} else {
|
||||
@@ -563,13 +571,21 @@ impl EventParser {
|
||||
None => return Ok(()),
|
||||
};
|
||||
|
||||
// 处理 inner instructions
|
||||
// 处理 inner instructions - 查找对应的 CPI log 进行 merge
|
||||
// 当 inner_index 有值时,只查找索引大于当前 inner_index 的 CPI log
|
||||
let mut inner_instruction_event: Option<DexEvent> = None;
|
||||
if let Some(inner_instructions_ref) = inner_instructions {
|
||||
let current_inner_idx = inner_index.unwrap_or(-1) as i32;
|
||||
|
||||
// 并行执行两个任务: 解析 inner event 和提取 swap_data
|
||||
let (inner_event_result, swap_data_result) = std::thread::scope(|s| {
|
||||
let inner_event_handle = s.spawn(|| {
|
||||
for inner_instruction in inner_instructions_ref.instructions.iter() {
|
||||
for (idx, inner_instruction) in inner_instructions_ref.instructions.iter().enumerate() {
|
||||
// 只查找索引大于当前 inner_index 的 CPI log
|
||||
if (idx as i32) <= current_inner_idx {
|
||||
continue;
|
||||
}
|
||||
|
||||
let inner_data = &inner_instruction.instruction.data;
|
||||
// 检查长度(需要 16 字节的 discriminator)
|
||||
if inner_data.len() < 16 {
|
||||
@@ -595,7 +611,7 @@ impl EventParser {
|
||||
parse_swap_data_from_next_instructions(
|
||||
&event,
|
||||
inner_instructions_ref,
|
||||
inner_index.unwrap_or(-1_i64) as i8,
|
||||
current_inner_idx as i8,
|
||||
accounts,
|
||||
)
|
||||
} else {
|
||||
@@ -735,3 +751,4 @@ impl EventParser {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user