mirror of
https://github.com/0xfnzero/solana-streamer.git
synced 2026-08-25 06:48:05 +00:00
chore: release v0.1.10 with event ID generation and cache fixes
This commit is contained in:
@@ -19,3 +19,5 @@ Cargo.lock
|
|||||||
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
||||||
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
||||||
#.idea/
|
#.idea/
|
||||||
|
|
||||||
|
.cargo/
|
||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "solana-streamer-sdk"
|
name = "solana-streamer-sdk"
|
||||||
version = "0.1.9"
|
version = "0.1.10"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
authors = ["William <byteblock6@gmail.com>", "sgxiang <sgxiang@gmail.com>", "wei <1415121722@qq.com>"]
|
authors = ["William <byteblock6@gmail.com>", "sgxiang <sgxiang@gmail.com>", "wei <1415121722@qq.com>"]
|
||||||
repository = "https://github.com/0xfnzero/solana-streamer"
|
repository = "https://github.com/0xfnzero/solana-streamer"
|
||||||
|
|||||||
@@ -41,14 +41,14 @@ Add the dependency to your `Cargo.toml`:
|
|||||||
|
|
||||||
```toml
|
```toml
|
||||||
# Add to your Cargo.toml
|
# Add to your Cargo.toml
|
||||||
solana-streamer-sdk = { path = "./solana-streamer", version = "0.1.9" }
|
solana-streamer-sdk = { path = "./solana-streamer", version = "0.1.10" }
|
||||||
```
|
```
|
||||||
|
|
||||||
### Use crates.io
|
### Use crates.io
|
||||||
|
|
||||||
```toml
|
```toml
|
||||||
# Add to your Cargo.toml
|
# Add to your Cargo.toml
|
||||||
solana-streamer-sdk = "0.1.9"
|
solana-streamer-sdk = "0.1.10"
|
||||||
```
|
```
|
||||||
|
|
||||||
## Usage Examples
|
## Usage Examples
|
||||||
|
|||||||
+2
-2
@@ -41,14 +41,14 @@ git clone https://github.com/0xfnzero/solana-streamer
|
|||||||
|
|
||||||
```toml
|
```toml
|
||||||
# 添加到您的 Cargo.toml
|
# 添加到您的 Cargo.toml
|
||||||
solana-streamer-sdk = { path = "./solana-streamer", version = "0.1.9" }
|
solana-streamer-sdk = { path = "./solana-streamer", version = "0.1.10" }
|
||||||
```
|
```
|
||||||
|
|
||||||
### 使用 crates.io
|
### 使用 crates.io
|
||||||
|
|
||||||
```toml
|
```toml
|
||||||
# 添加到您的 Cargo.toml
|
# 添加到您的 Cargo.toml
|
||||||
solana-streamer-sdk = "0.1.9"
|
solana-streamer-sdk = "0.1.10"
|
||||||
```
|
```
|
||||||
|
|
||||||
## 使用示例
|
## 使用示例
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ use borsh::{BorshDeserialize, BorshSerialize};
|
|||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use solana_sdk::pubkey::Pubkey;
|
use solana_sdk::pubkey::Pubkey;
|
||||||
use solana_transaction_status::UiInstruction;
|
use solana_transaction_status::UiInstruction;
|
||||||
use std::sync::Arc;
|
use std::{hash::{DefaultHasher, Hash, Hasher}, sync::Arc};
|
||||||
use tokio::sync::Mutex;
|
use tokio::sync::Mutex;
|
||||||
|
|
||||||
// Object pool size configuration
|
// Object pool size configuration
|
||||||
@@ -320,7 +320,11 @@ impl EventMetadata {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_id(&mut self, id: String) {
|
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>) {
|
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,
|
program_received_time_ms: i64,
|
||||||
bot_wallet: Option<Pubkey>,
|
bot_wallet: Option<Pubkey>,
|
||||||
) -> Result<Vec<Box<dyn UnifiedEvent>>> {
|
) -> Result<Vec<Box<dyn UnifiedEvent>>> {
|
||||||
// 生成缓存键
|
|
||||||
let cache_key = format!("{}_{}_{}", signature, slot.unwrap_or(0), program_received_time_ms);
|
|
||||||
|
|
||||||
// 尝试从缓存获取
|
// TODO: bug - 待优化
|
||||||
if let Some(cached_events) = PARSE_CACHE.get(&cache_key).await {
|
// // 生成缓存键
|
||||||
return Ok(cached_events);
|
// 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);
|
||||||
|
// }
|
||||||
|
|
||||||
let transaction = tx.transaction;
|
let transaction = tx.transaction;
|
||||||
// 检查交易元数据
|
// 检查交易元数据
|
||||||
@@ -443,7 +445,7 @@ pub trait EventParser: Send + Sync {
|
|||||||
let result = self.process_events(instruction_events, bot_wallet);
|
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)
|
Ok(result)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user