mirror of
https://github.com/0xfnzero/solana-streamer.git
synced 2026-08-23 05:48:05 +00:00
feat: upgrade to v0.4.5
This commit is contained in:
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "solana-streamer-sdk"
|
name = "solana-streamer-sdk"
|
||||||
version = "0.4.4"
|
version = "0.4.5"
|
||||||
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"
|
||||||
|
|||||||
@@ -46,14 +46,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.4.3" }
|
solana-streamer-sdk = { path = "./solana-streamer", version = "0.4.5" }
|
||||||
```
|
```
|
||||||
|
|
||||||
### Use crates.io
|
### Use crates.io
|
||||||
|
|
||||||
```toml
|
```toml
|
||||||
# Add to your Cargo.toml
|
# Add to your Cargo.toml
|
||||||
solana-streamer-sdk = "0.4.3"
|
solana-streamer-sdk = "0.4.5"
|
||||||
```
|
```
|
||||||
|
|
||||||
## Configuration System
|
## Configuration System
|
||||||
|
|||||||
+2
-2
@@ -46,14 +46,14 @@ git clone https://github.com/0xfnzero/solana-streamer
|
|||||||
|
|
||||||
```toml
|
```toml
|
||||||
# 添加到您的 Cargo.toml
|
# 添加到您的 Cargo.toml
|
||||||
solana-streamer-sdk = { path = "./solana-streamer", version = "0.4.4" }
|
solana-streamer-sdk = { path = "./solana-streamer", version = "0.4.5" }
|
||||||
```
|
```
|
||||||
|
|
||||||
### 使用 crates.io
|
### 使用 crates.io
|
||||||
|
|
||||||
```toml
|
```toml
|
||||||
# 添加到您的 Cargo.toml
|
# 添加到您的 Cargo.toml
|
||||||
solana-streamer-sdk = "0.4.4"
|
solana-streamer-sdk = "0.4.5"
|
||||||
```
|
```
|
||||||
|
|
||||||
## 配置系统
|
## 配置系统
|
||||||
|
|||||||
@@ -21,6 +21,8 @@ use crate::streaming::event_parser::protocols::raydium_cpmm::parser::RAYDIUM_CPM
|
|||||||
use crate::streaming::event_parser::Protocol;
|
use crate::streaming::event_parser::Protocol;
|
||||||
use crate::streaming::grpc::AccountPretty;
|
use crate::streaming::grpc::AccountPretty;
|
||||||
|
|
||||||
|
use spl_token::state::Mint;
|
||||||
|
|
||||||
/// 通用事件解析器配置
|
/// 通用事件解析器配置
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct AccountEventParseConfig {
|
pub struct AccountEventParseConfig {
|
||||||
@@ -286,43 +288,34 @@ impl AccountEventParser {
|
|||||||
account: &AccountPretty,
|
account: &AccountPretty,
|
||||||
metadata: EventMetadata,
|
metadata: EventMetadata,
|
||||||
) -> Option<Box<dyn UnifiedEvent>> {
|
) -> Option<Box<dyn UnifiedEvent>> {
|
||||||
use solana_program::program_pack::Pack;
|
let pubkey = account.pubkey;
|
||||||
use spl_token::state::Mint;
|
let executable = account.executable;
|
||||||
match Mint::unpack_from_slice(&account.data) {
|
let lamports = account.lamports;
|
||||||
Ok(mint) => {
|
let owner = account.owner;
|
||||||
|
let rent_epoch = account.rent_epoch;
|
||||||
|
if account.data.len() >= Mint::LEN {
|
||||||
|
if let Ok(mint) = Mint::unpack_from_slice(&account.data) {
|
||||||
let mut event = TokenInfoEvent {
|
let mut event = TokenInfoEvent {
|
||||||
metadata,
|
metadata,
|
||||||
pubkey: account.pubkey,
|
pubkey,
|
||||||
executable: account.executable,
|
executable,
|
||||||
lamports: account.lamports,
|
lamports,
|
||||||
owner: account.owner,
|
owner,
|
||||||
rent_epoch: account.rent_epoch,
|
rent_epoch,
|
||||||
supply: mint.supply,
|
supply: mint.supply,
|
||||||
decimals: mint.decimals,
|
decimals: mint.decimals,
|
||||||
};
|
};
|
||||||
event.set_handle_us(elapsed_micros_since(account.recv_us));
|
let recv_delta = elapsed_micros_since(account.recv_us);
|
||||||
return Some(Box::new(event));
|
event.set_handle_us(recv_delta);
|
||||||
}
|
|
||||||
Err(_) => {
|
|
||||||
let mut event = TokenAccountEvent {
|
|
||||||
metadata,
|
|
||||||
pubkey: account.pubkey,
|
|
||||||
executable: account.executable,
|
|
||||||
lamports: account.lamports,
|
|
||||||
owner: account.owner,
|
|
||||||
rent_epoch: account.rent_epoch,
|
|
||||||
amount: None,
|
|
||||||
};
|
|
||||||
match Account::unpack(&account.data) {
|
|
||||||
Ok(info) => {
|
|
||||||
event.amount = Some(info.amount);
|
|
||||||
}
|
|
||||||
Err(_) => {}
|
|
||||||
}
|
|
||||||
event.set_handle_us(elapsed_micros_since(account.recv_us));
|
|
||||||
return Some(Box::new(event));
|
return Some(Box::new(event));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
let amount = Account::unpack(&account.data).ok().map(|info| info.amount);
|
||||||
|
let mut event =
|
||||||
|
TokenAccountEvent { metadata, pubkey, executable, lamports, owner, rent_epoch, amount };
|
||||||
|
let recv_delta = elapsed_micros_since(account.recv_us);
|
||||||
|
event.set_handle_us(recv_delta);
|
||||||
|
Some(Box::new(event))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn parse_nonce_account_event(
|
pub fn parse_nonce_account_event(
|
||||||
|
|||||||
Reference in New Issue
Block a user