mirror of
https://github.com/0xfnzero/solana-streamer.git
synced 2026-08-15 01:48:05 +00:00
chore: release v0.1.10 with event ID generation and cache fixes
This commit is contained in:
@@ -2,7 +2,7 @@ use borsh::{BorshDeserialize, BorshSerialize};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use solana_sdk::pubkey::Pubkey;
|
||||
use solana_transaction_status::UiInstruction;
|
||||
use std::sync::Arc;
|
||||
use std::{hash::{DefaultHasher, Hash, Hasher}, sync::Arc};
|
||||
use tokio::sync::Mutex;
|
||||
|
||||
// Object pool size configuration
|
||||
@@ -320,7 +320,11 @@ impl EventMetadata {
|
||||
}
|
||||
|
||||
pub fn set_id(&mut self, id: String) {
|
||||
self.id = id;
|
||||
let _id = format!("{}-{}-{}", self.signature, self.event_type.to_string(), id);
|
||||
let mut hasher = DefaultHasher::new();
|
||||
_id.hash(&mut hasher);
|
||||
let hash_value = hasher.finish();
|
||||
self.id = format!("{:x}", hash_value);
|
||||
}
|
||||
|
||||
pub fn set_transfer_datas(&mut self, transfer_datas: Vec<TransferData>) {
|
||||
|
||||
@@ -271,13 +271,15 @@ pub trait EventParser: Send + Sync {
|
||||
program_received_time_ms: i64,
|
||||
bot_wallet: Option<Pubkey>,
|
||||
) -> Result<Vec<Box<dyn UnifiedEvent>>> {
|
||||
// 生成缓存键
|
||||
let cache_key = format!("{}_{}_{}", signature, slot.unwrap_or(0), program_received_time_ms);
|
||||
|
||||
// TODO: bug - 待优化
|
||||
// // 生成缓存键
|
||||
// let cache_key = format!("{}_{}_{}", signature, slot.unwrap_or(0), program_received_time_ms);
|
||||
|
||||
// 尝试从缓存获取
|
||||
if let Some(cached_events) = PARSE_CACHE.get(&cache_key).await {
|
||||
return Ok(cached_events);
|
||||
}
|
||||
// // 尝试从缓存获取
|
||||
// if let Some(cached_events) = PARSE_CACHE.get(&cache_key).await {
|
||||
// return Ok(cached_events);
|
||||
// }
|
||||
|
||||
let transaction = tx.transaction;
|
||||
// 检查交易元数据
|
||||
@@ -443,7 +445,7 @@ pub trait EventParser: Send + Sync {
|
||||
let result = self.process_events(instruction_events, bot_wallet);
|
||||
|
||||
// 缓存结果
|
||||
PARSE_CACHE.set(cache_key, result.clone()).await;
|
||||
// PARSE_CACHE.set(cache_key, result.clone()).await;
|
||||
|
||||
Ok(result)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user