rename grpc to streaming

This commit is contained in:
wood
2025-07-10 03:24:13 +08:00
parent f1649ac933
commit 516b682519
28 changed files with 33 additions and 39 deletions
View File
Regular → Executable
View File
+3 -6
View File
@@ -1,17 +1,15 @@
pub mod common;
pub mod constants;
pub mod event_parser;
pub mod grpc;
pub mod instruction;
pub mod protos;
pub mod swqos;
pub mod streaming;
pub mod trading;
use std::sync::Arc;
use std::sync::Mutex;
use rustls::crypto::{ring::default_provider, CryptoProvider};
use solana_hash::Hash;
use solana_sdk::{
pubkey::Pubkey,
signature::{Keypair, Signer},
@@ -20,10 +18,9 @@ use swqos::SwqosClient;
use common::{PriorityFee, SolanaRpcClient, TradeConfig};
use constants::trade_platform::{PUMPFUN, PUMPFUN_SWAP, BONK};
use constants::trade_type::{COPY_BUY, SNIPER_BUY};
use constants::trade_type::COPY_BUY;
use crate::event_parser::protocols::pumpfun::PumpFunTradeEvent;
use crate::streaming::event_parser::protocols::pumpfun::PumpFunTradeEvent;
use crate::swqos::SwqosConfig;
use crate::trading::core::params::PumpFunParams;
use crate::trading::core::params::PumpFunSellParams;
+2 -2
View File
@@ -3,7 +3,7 @@ use std::{str::FromStr, sync::Arc};
use sol_trade_sdk::{
common::{bonding_curve::BondingCurveAccount, AnyResult, PriorityFee, TradeConfig},
constants::{pumpfun::global_constants::TOKEN_TOTAL_SUPPLY, trade_type},
event_parser::{
streaming::event_parser::{
protocols::{
bonk::{BonkPoolCreateEvent, BonkTradeEvent}, pumpfun::{PumpFunCreateTokenEvent, PumpFunTradeEvent}, pumpswap::{
PumpSwapBuyEvent, PumpSwapCreatePoolEvent, PumpSwapDepositEvent, PumpSwapSellEvent,
@@ -12,7 +12,7 @@ use sol_trade_sdk::{
},
Protocol, UnifiedEvent,
},
grpc::{ShredStreamGrpc, YellowstoneGrpc},
streaming::{ShredStreamGrpc, YellowstoneGrpc},
match_event,
swqos::{SwqosConfig, SwqosRegion},
trading::{
+4 -4
View File
@@ -6,12 +6,12 @@ pub mod utils;
macro_rules! impl_unified_event {
// 带有自定义ID表达式的版本
($struct_name:ident, $($field:ident),*) => {
impl $crate::event_parser::core::traits::UnifiedEvent for $struct_name {
impl $crate::streaming::event_parser::core::traits::UnifiedEvent for $struct_name {
fn id(&self) -> &str {
&self.metadata.id
}
fn event_type(&self) -> $crate::event_parser::common::types::EventType {
fn event_type(&self) -> $crate::streaming::event_parser::common::types::EventType {
self.metadata.event_type.clone()
}
@@ -35,11 +35,11 @@ macro_rules! impl_unified_event {
self
}
fn clone_boxed(&self) -> Box<dyn $crate::event_parser::core::traits::UnifiedEvent> {
fn clone_boxed(&self) -> Box<dyn $crate::streaming::event_parser::core::traits::UnifiedEvent> {
Box::new(self.clone())
}
fn merge(&mut self, other: Box<dyn $crate::event_parser::core::traits::UnifiedEvent>) {
fn merge(&mut self, other: Box<dyn $crate::streaming::event_parser::core::traits::UnifiedEvent>) {
if let Some(e) = other.as_any().downcast_ref::<$struct_name>() {
$(
self.$field = e.$field.clone();
+2 -2
View File
@@ -8,8 +8,8 @@ use solana_transaction_status::{
use std::collections::HashMap;
use std::fmt::Debug;
use crate::{
event_parser::{common::{utils::*, EventMetadata, EventType, ProtocolType}, protocols::{pumpfun::{PumpFunCreateTokenEvent, PumpFunTradeEvent}, bonk::{BonkPoolCreateEvent, BonkTradeEvent}}},
use crate::streaming::event_parser::{
common::{utils::*, EventMetadata, EventType, ProtocolType}, protocols::{pumpfun::{PumpFunCreateTokenEvent, PumpFunTradeEvent}, bonk::{BonkPoolCreateEvent, BonkTradeEvent}},
};
/// 统一事件接口 - 所有协议的事件都需要实现此trait
+1 -1
View File
@@ -2,7 +2,7 @@ use anyhow::{anyhow, Result};
use solana_sdk::pubkey::Pubkey;
use std::sync::Arc;
use crate::event_parser::protocols::{
use crate::streaming::event_parser::protocols::{
pumpfun::parser::PUMPFUN_PROGRAM_ID, pumpswap::parser::PUMPSWAP_PROGRAM_ID, bonk::parser::BONK_PROGRAM_ID, BonkEventParser,
};
View File
@@ -1,7 +1,7 @@
use crate::event_parser::protocols::bonk::types::{
use crate::streaming::event_parser::protocols::bonk::types::{
CurveParams, MintParams, PoolStatus, TradeDirection, VestingParams,
};
use crate::event_parser::{common::EventMetadata, core::traits::UnifiedEvent};
use crate::streaming::event_parser::{common::EventMetadata, core::traits::UnifiedEvent};
use crate::impl_unified_event;
use borsh::BorshDeserialize;
use serde::{Deserialize, Serialize};
@@ -1,7 +1,7 @@
use solana_sdk::{instruction::CompiledInstruction, pubkey::Pubkey};
use solana_transaction_status::UiCompiledInstruction;
use crate::event_parser::{
use crate::streaming::event_parser::{
common::{utils::*, EventMetadata, EventType, ProtocolType},
core::traits::{EventParser, GenericEventParseConfig, GenericEventParser, UnifiedEvent},
protocols::bonk::{
@@ -2,7 +2,7 @@ use borsh::BorshDeserialize;
use serde::{Deserialize, Serialize};
use solana_sdk::pubkey::Pubkey;
use crate::event_parser::{common::EventMetadata, core::traits::UnifiedEvent};
use crate::streaming::event_parser::{common::EventMetadata, core::traits::UnifiedEvent};
use crate::impl_unified_event;
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize, BorshDeserialize)]
@@ -1,7 +1,7 @@
use solana_sdk::{instruction::CompiledInstruction, pubkey::Pubkey};
use solana_transaction_status::UiCompiledInstruction;
use crate::event_parser::{
use crate::streaming::event_parser::{
common::{utils::*, EventMetadata, EventType, ProtocolType},
core::traits::{EventParser, GenericEventParseConfig, GenericEventParser, UnifiedEvent},
protocols::pumpfun::{discriminators, PumpFunCreateTokenEvent, PumpFunTradeEvent},
@@ -2,7 +2,7 @@ use borsh::BorshDeserialize;
use serde::{Deserialize, Serialize};
use solana_sdk::pubkey::Pubkey;
use crate::event_parser::{common::EventMetadata, core::traits::UnifiedEvent};
use crate::streaming::event_parser::{common::EventMetadata, core::traits::UnifiedEvent};
use crate::impl_unified_event;
/// 买入事件
@@ -1,8 +1,8 @@
use solana_sdk::{instruction::CompiledInstruction, pubkey::Pubkey};
use solana_transaction_status::UiCompiledInstruction;
use crate::event_parser::{
common::{utils::*, EventMetadata, EventType, ProtocolType},
use crate::streaming::event_parser::{
common::{EventMetadata, EventType, ProtocolType, read_u64_le},
core::traits::{EventParser, GenericEventParseConfig, GenericEventParser, UnifiedEvent},
protocols::pumpswap::{
discriminators, PumpSwapBuyEvent, PumpSwapCreatePoolEvent, PumpSwapDepositEvent,
+1
View File
@@ -1,6 +1,7 @@
pub mod yellow_stone;
pub mod yellow_stone_sub_system;
pub mod shred_stream;
pub mod event_parser;
pub use yellow_stone::YellowstoneGrpc;
pub use yellow_stone_sub_system::{SystemEvent, TransferInfo};
@@ -8,11 +8,7 @@ use log::error;
use solana_sdk::transaction::VersionedTransaction;
use crate::common::AnyResult;
use crate::event_parser::protocols::pumpfun::{PumpFunCreateTokenEvent, PumpFunTradeEvent};
use crate::event_parser::protocols::bonk::{
BonkPoolCreateEvent, BonkTradeEvent,
};
use crate::event_parser::{EventParserFactory, Protocol, UnifiedEvent};
use crate::streaming::event_parser::{EventParserFactory, Protocol, UnifiedEvent};
use crate::protos::shredstream::shredstream_proxy_client::ShredstreamProxyClient;
use crate::protos::shredstream::SubscribeEntriesRequest;
@@ -16,16 +16,8 @@ use yellowstone_grpc_proto::geyser::{
SubscribeUpdateTransaction,
};
// use crate::common::pumpfun::logs_data::{DexInstruction, TransferInfo};
// use crate::common::pumpfun::logs_events::{PumpfunEvent, SystemEvent};
// use crate::common::pumpfun::logs_filters::LogFilter;
use crate::common::AnyResult;
use crate::constants::pumpfun::trade;
use crate::event_parser::protocols::pumpfun::{PumpFunCreateTokenEvent, PumpFunTradeEvent};
use crate::event_parser::protocols::bonk::{
BonkPoolCreateEvent, BonkTradeEvent,
};
use crate::event_parser::{EventParserFactory, Protocol, UnifiedEvent};
use crate::streaming::event_parser::{EventParserFactory, Protocol, UnifiedEvent};
type TransactionsFilterMap = HashMap<String, SubscribeRequestFilterTransactions>;
@@ -1,4 +1,4 @@
use crate::{common::AnyResult, grpc::yellow_stone::{TransactionPretty, YellowstoneGrpc}};
use crate::{common::AnyResult, streaming::yellow_stone::{TransactionPretty, YellowstoneGrpc}};
use solana_program::pubkey;
use solana_sdk::{pubkey::Pubkey, transaction::VersionedTransaction};
use futures::{channel::mpsc, sink::Sink, Stream, StreamExt, SinkExt};
Regular → Executable
View File
+9 -1
View File
@@ -8,7 +8,15 @@ use solana_sdk::{
};
use spl_associated_token_account::get_associated_token_address;
use pumpfun_program::accounts::BondingCurveAccount as PumpfunBondingCurveAccount;
use crate::{common::{bonding_curve::BondingCurveAccount, global::GlobalAccount, PriorityFee, SolanaRpcClient}, constants::{self, pumpfun::{self, global_constants::{CREATOR_FEE, FEE_BASIS_POINTS}, trade::DEFAULT_SLIPPAGE}}, event_parser::protocols::pumpfun::PumpFunTradeEvent};
use crate::{
common::{
bonding_curve::BondingCurveAccount, global::GlobalAccount, PriorityFee, SolanaRpcClient
},
constants::{
self, pumpfun::{global_constants::{CREATOR_FEE, FEE_BASIS_POINTS}, trade::DEFAULT_SLIPPAGE}
},
streaming::event_parser::protocols::pumpfun::PumpFunTradeEvent
};
lazy_static::lazy_static! {
static ref ACCOUNT_CACHE: RwLock<HashMap<Pubkey, Arc<GlobalAccount>>> = RwLock::new(HashMap::new());