mirror of
https://github.com/0xfnzero/solana-streamer.git
synced 2026-08-13 08:58:05 +00:00
Merge branch '0xfnzero:main' into dev-work
This commit is contained in:
@@ -24,6 +24,7 @@ serde-big-array = "0.5.1"
|
||||
futures = "0.3.32"
|
||||
bincode = "1.3"
|
||||
anyhow = "1.0.102"
|
||||
bs58 = "0.5.1"
|
||||
yellowstone-grpc-client = { version = "10.2.0" }
|
||||
yellowstone-grpc-proto = { version = "10.1.1" }
|
||||
tokio = { version = "1.50.0", features = ["full", "rt-multi-thread"]}
|
||||
|
||||
@@ -198,6 +198,9 @@ pub struct EventMetadata {
|
||||
pub swap_data: Option<SwapData>,
|
||||
pub outer_index: i64,
|
||||
pub inner_index: Option<i64>,
|
||||
/// Transaction message recent blockhash as base58 string (same encoding as signature), when available.
|
||||
#[serde(default)]
|
||||
pub recent_blockhash: Option<String>,
|
||||
}
|
||||
|
||||
impl EventMetadata {
|
||||
@@ -214,6 +217,7 @@ impl EventMetadata {
|
||||
inner_index: Option<i64>,
|
||||
recv_us: i64,
|
||||
tx_index: Option<u64>,
|
||||
recent_blockhash: Option<String>,
|
||||
) -> Self {
|
||||
Self {
|
||||
signature,
|
||||
@@ -229,6 +233,7 @@ impl EventMetadata {
|
||||
outer_index,
|
||||
inner_index,
|
||||
tx_index,
|
||||
recent_blockhash,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -82,6 +82,11 @@ impl EventParser {
|
||||
.collect();
|
||||
// 解析指令事件
|
||||
let instructions = &message.instructions;
|
||||
let recent_blockhash = if message.recent_blockhash.is_empty() {
|
||||
None
|
||||
} else {
|
||||
Some(bs58::encode(&message.recent_blockhash).into_string())
|
||||
};
|
||||
Self::parse_instruction_events_from_grpc_transaction(
|
||||
protocols,
|
||||
event_type_filter,
|
||||
@@ -94,6 +99,7 @@ impl EventParser {
|
||||
&inner_instructions,
|
||||
bot_wallet,
|
||||
tx_index,
|
||||
recent_blockhash,
|
||||
adapter_callback,
|
||||
)
|
||||
.await?;
|
||||
@@ -128,6 +134,7 @@ impl EventParser {
|
||||
});
|
||||
// 获取交易的指令和账户
|
||||
let compiled_instructions = transaction.message.instructions();
|
||||
let recent_blockhash = Some(transaction.message.recent_blockhash().to_string());
|
||||
let mut accounts: Vec<Pubkey> = accounts.to_vec();
|
||||
// 检查交易中是否包含程序
|
||||
let has_program = accounts
|
||||
@@ -160,6 +167,7 @@ impl EventParser {
|
||||
None,
|
||||
bot_wallet,
|
||||
tx_index,
|
||||
recent_blockhash.as_deref(),
|
||||
inner_instructions,
|
||||
adapter_callback.clone(),
|
||||
)?;
|
||||
@@ -182,6 +190,7 @@ impl EventParser {
|
||||
Some(inner_index as i64),
|
||||
bot_wallet,
|
||||
tx_index,
|
||||
recent_blockhash.as_deref(),
|
||||
Some(&inner_instructions),
|
||||
adapter_callback.clone(),
|
||||
)?;
|
||||
@@ -214,6 +223,7 @@ impl EventParser {
|
||||
inner_instructions: &[yellowstone_grpc_proto::prelude::InnerInstructions],
|
||||
bot_wallet: Option<Pubkey>,
|
||||
tx_index: Option<u64>,
|
||||
recent_blockhash: Option<String>,
|
||||
callback: Arc<dyn for<'a> Fn(&'a DexEvent) + Send + Sync>,
|
||||
) -> anyhow::Result<()> {
|
||||
// 获取交易的指令和账户
|
||||
@@ -249,6 +259,7 @@ impl EventParser {
|
||||
None,
|
||||
bot_wallet,
|
||||
tx_index,
|
||||
recent_blockhash.as_deref(),
|
||||
inner_instructions,
|
||||
callback.clone(),
|
||||
)?;
|
||||
@@ -279,6 +290,7 @@ impl EventParser {
|
||||
Some(inner_index as i64),
|
||||
bot_wallet,
|
||||
tx_index,
|
||||
recent_blockhash.as_deref(),
|
||||
Some(&inner_instructions),
|
||||
callback.clone(),
|
||||
)?;
|
||||
@@ -308,6 +320,7 @@ impl EventParser {
|
||||
inner_index: Option<i64>,
|
||||
bot_wallet: Option<Pubkey>,
|
||||
tx_index: Option<u64>,
|
||||
recent_blockhash: Option<&str>,
|
||||
inner_instructions: Option<&yellowstone_grpc_proto::prelude::InnerInstructions>,
|
||||
callback: Arc<dyn for<'a> Fn(&'a DexEvent) + Send + Sync>,
|
||||
) -> anyhow::Result<()> {
|
||||
@@ -347,6 +360,7 @@ impl EventParser {
|
||||
inner_index,
|
||||
recv_us,
|
||||
tx_index,
|
||||
recent_blockhash.map(|s| s.to_string()),
|
||||
);
|
||||
|
||||
if is_cu_program {
|
||||
@@ -465,6 +479,7 @@ impl EventParser {
|
||||
inner_index: Option<i64>,
|
||||
bot_wallet: Option<Pubkey>,
|
||||
tx_index: Option<u64>,
|
||||
recent_blockhash: Option<&str>,
|
||||
inner_instructions: Option<&InnerInstructions>,
|
||||
callback: Arc<dyn for<'a> Fn(&'a DexEvent) + Send + Sync>,
|
||||
) -> anyhow::Result<()> {
|
||||
@@ -505,6 +520,7 @@ impl EventParser {
|
||||
inner_index,
|
||||
recv_us,
|
||||
tx_index,
|
||||
recent_blockhash.map(|s| s.to_string()),
|
||||
);
|
||||
|
||||
if is_cu_program {
|
||||
|
||||
@@ -31,6 +31,7 @@ impl BlockMetaEvent {
|
||||
None,
|
||||
recv_us,
|
||||
None,
|
||||
None, // recent_blockhash not applicable for block meta
|
||||
);
|
||||
Self { metadata, slot, block_hash }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user