mirror of
https://github.com/0xfnzero/solana-streamer.git
synced 2026-08-23 05:48:05 +00:00
refactor(events): recent_blockhash as base58 string (same as signature)
- EventMetadata.recent_blockhash: Option<Vec<u8>> -> Option<String> - Add bs58 dependency; gRPC path: bs58::encode message bytes - VersionedTransaction path: use Hash::to_string() (base58) - parse_events_from_grpc_instruction/parse_events_from_instruction: accept Option<&str> Made-with: Cursor
This commit is contained in:
@@ -25,6 +25,7 @@ serde-big-array = "0.5.1"
|
|||||||
futures = "0.3.32"
|
futures = "0.3.32"
|
||||||
bincode = "1.3"
|
bincode = "1.3"
|
||||||
anyhow = "1.0.102"
|
anyhow = "1.0.102"
|
||||||
|
bs58 = "0.5.1"
|
||||||
yellowstone-grpc-client = { version = "10.2.0" }
|
yellowstone-grpc-client = { version = "10.2.0" }
|
||||||
yellowstone-grpc-proto = { version = "10.1.1" }
|
yellowstone-grpc-proto = { version = "10.1.1" }
|
||||||
tokio = { version = "1.49.0", features = ["full", "rt-multi-thread"]}
|
tokio = { version = "1.49.0", features = ["full", "rt-multi-thread"]}
|
||||||
|
|||||||
@@ -312,9 +312,9 @@ pub struct EventMetadata {
|
|||||||
pub swap_data: Option<SwapData>,
|
pub swap_data: Option<SwapData>,
|
||||||
pub outer_index: i64,
|
pub outer_index: i64,
|
||||||
pub inner_index: Option<i64>,
|
pub inner_index: Option<i64>,
|
||||||
/// Transaction message recent blockhash (32 bytes), when available.
|
/// Transaction message recent blockhash as base58 string (same encoding as signature), when available.
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub recent_blockhash: Option<Vec<u8>>,
|
pub recent_blockhash: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl EventMetadata {
|
impl EventMetadata {
|
||||||
@@ -331,7 +331,7 @@ impl EventMetadata {
|
|||||||
inner_index: Option<i64>,
|
inner_index: Option<i64>,
|
||||||
recv_us: i64,
|
recv_us: i64,
|
||||||
tx_index: Option<u64>,
|
tx_index: Option<u64>,
|
||||||
recent_blockhash: Option<Vec<u8>>,
|
recent_blockhash: Option<String>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self {
|
Self {
|
||||||
signature,
|
signature,
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ impl EventParser {
|
|||||||
let recent_blockhash = if message.recent_blockhash.is_empty() {
|
let recent_blockhash = if message.recent_blockhash.is_empty() {
|
||||||
None
|
None
|
||||||
} else {
|
} else {
|
||||||
Some(message.recent_blockhash.clone())
|
Some(bs58::encode(&message.recent_blockhash).into_string())
|
||||||
};
|
};
|
||||||
Self::parse_instruction_events_from_grpc_transaction(
|
Self::parse_instruction_events_from_grpc_transaction(
|
||||||
protocols,
|
protocols,
|
||||||
@@ -134,7 +134,7 @@ impl EventParser {
|
|||||||
});
|
});
|
||||||
// 获取交易的指令和账户
|
// 获取交易的指令和账户
|
||||||
let compiled_instructions = transaction.message.instructions();
|
let compiled_instructions = transaction.message.instructions();
|
||||||
let recent_blockhash = Some(transaction.message.recent_blockhash().to_bytes().to_vec());
|
let recent_blockhash = Some(transaction.message.recent_blockhash().to_string());
|
||||||
let mut accounts: Vec<Pubkey> = accounts.to_vec();
|
let mut accounts: Vec<Pubkey> = accounts.to_vec();
|
||||||
// 检查交易中是否包含程序
|
// 检查交易中是否包含程序
|
||||||
let has_program = accounts
|
let has_program = accounts
|
||||||
@@ -223,7 +223,7 @@ impl EventParser {
|
|||||||
inner_instructions: &[yellowstone_grpc_proto::prelude::InnerInstructions],
|
inner_instructions: &[yellowstone_grpc_proto::prelude::InnerInstructions],
|
||||||
bot_wallet: Option<Pubkey>,
|
bot_wallet: Option<Pubkey>,
|
||||||
tx_index: Option<u64>,
|
tx_index: Option<u64>,
|
||||||
recent_blockhash: Option<Vec<u8>>,
|
recent_blockhash: Option<String>,
|
||||||
callback: Arc<dyn for<'a> Fn(&'a DexEvent) + Send + Sync>,
|
callback: Arc<dyn for<'a> Fn(&'a DexEvent) + Send + Sync>,
|
||||||
) -> anyhow::Result<()> {
|
) -> anyhow::Result<()> {
|
||||||
// 获取交易的指令和账户
|
// 获取交易的指令和账户
|
||||||
@@ -320,7 +320,7 @@ impl EventParser {
|
|||||||
inner_index: Option<i64>,
|
inner_index: Option<i64>,
|
||||||
bot_wallet: Option<Pubkey>,
|
bot_wallet: Option<Pubkey>,
|
||||||
tx_index: Option<u64>,
|
tx_index: Option<u64>,
|
||||||
recent_blockhash: Option<&[u8]>,
|
recent_blockhash: Option<&str>,
|
||||||
inner_instructions: Option<&yellowstone_grpc_proto::prelude::InnerInstructions>,
|
inner_instructions: Option<&yellowstone_grpc_proto::prelude::InnerInstructions>,
|
||||||
callback: Arc<dyn for<'a> Fn(&'a DexEvent) + Send + Sync>,
|
callback: Arc<dyn for<'a> Fn(&'a DexEvent) + Send + Sync>,
|
||||||
) -> anyhow::Result<()> {
|
) -> anyhow::Result<()> {
|
||||||
@@ -360,7 +360,7 @@ impl EventParser {
|
|||||||
inner_index,
|
inner_index,
|
||||||
recv_us,
|
recv_us,
|
||||||
tx_index,
|
tx_index,
|
||||||
recent_blockhash.map(|s| s.to_vec()),
|
recent_blockhash.map(|s| s.to_string()),
|
||||||
);
|
);
|
||||||
|
|
||||||
if is_cu_program {
|
if is_cu_program {
|
||||||
@@ -479,7 +479,7 @@ impl EventParser {
|
|||||||
inner_index: Option<i64>,
|
inner_index: Option<i64>,
|
||||||
bot_wallet: Option<Pubkey>,
|
bot_wallet: Option<Pubkey>,
|
||||||
tx_index: Option<u64>,
|
tx_index: Option<u64>,
|
||||||
recent_blockhash: Option<&[u8]>,
|
recent_blockhash: Option<&str>,
|
||||||
inner_instructions: Option<&InnerInstructions>,
|
inner_instructions: Option<&InnerInstructions>,
|
||||||
callback: Arc<dyn for<'a> Fn(&'a DexEvent) + Send + Sync>,
|
callback: Arc<dyn for<'a> Fn(&'a DexEvent) + Send + Sync>,
|
||||||
) -> anyhow::Result<()> {
|
) -> anyhow::Result<()> {
|
||||||
@@ -520,7 +520,7 @@ impl EventParser {
|
|||||||
inner_index,
|
inner_index,
|
||||||
recv_us,
|
recv_us,
|
||||||
tx_index,
|
tx_index,
|
||||||
recent_blockhash.map(|s| s.to_vec()),
|
recent_blockhash.map(|s| s.to_string()),
|
||||||
);
|
);
|
||||||
|
|
||||||
if is_cu_program {
|
if is_cu_program {
|
||||||
|
|||||||
Reference in New Issue
Block a user