From 2c3d617c6e418609e752d819c3130a2d8b28594d Mon Sep 17 00:00:00 2001 From: Wood Date: Sat, 20 Dec 2025 16:45:29 +0800 Subject: [PATCH] feat(swqos): add SWQOS provider blacklist configuration - Add SWQOS_BLACKLIST constant for disabling specific providers - Add SwqosConfig::is_blacklisted() method to check blacklist status - Skip blacklisted providers during client initialization with warning - Remove NextBlock references from README, README_CN and examples - NextBlock is blacklisted by default, can be enabled by removing from SWQOS_BLACKLIST --- README.md | 4 +--- README_CN.md | 4 +--- examples/trading_client/src/main.rs | 1 - src/lib.rs | 5 +++++ src/swqos/mod.rs | 12 ++++++++++++ 5 files changed, 19 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 38618ca..89e1f63 100644 --- a/README.md +++ b/README.md @@ -115,7 +115,6 @@ let commitment = CommitmentConfig::processed(); let swqos_configs: Vec = vec![ SwqosConfig::Default(rpc_url.clone()), SwqosConfig::Jito("your uuid".to_string(), SwqosRegion::Frankfurt, None), - SwqosConfig::NextBlock("your api_token".to_string(), SwqosRegion::Frankfurt, None), SwqosConfig::Bloxroute("your api_token".to_string(), SwqosRegion::Frankfurt, None), SwqosConfig::ZeroSlot("your api_token".to_string(), SwqosRegion::Frankfurt, None), SwqosConfig::Temporal("your api_token".to_string(), SwqosRegion::Frankfurt, None), @@ -233,7 +232,7 @@ let jito_config = SwqosConfig::Jito( ); // Using default regional endpoint (third parameter is None) -let nextblock_config = SwqosConfig::NextBlock( +let bloxroute_config = SwqosConfig::Bloxroute( "your_api_token".to_string(), SwqosRegion::NewYork, // Will use the default endpoint for this region None // No custom URL, uses SwqosRegion @@ -273,7 +272,6 @@ Use Durable Nonce to implement transaction replay protection and optimize transa You can apply for a key through the official website: [Community Website](https://fnzero.dev/swqos) - **Jito**: High-performance block space -- **NextBlock**: Fast transaction execution - **ZeroSlot**: Zero-latency transactions - **Temporal**: Time-sensitive transactions - **Bloxroute**: Blockchain network acceleration diff --git a/README_CN.md b/README_CN.md index 5bc43a1..a4d9b8a 100755 --- a/README_CN.md +++ b/README_CN.md @@ -115,7 +115,6 @@ let commitment = CommitmentConfig::processed(); let swqos_configs: Vec = vec![ SwqosConfig::Default(rpc_url.clone()), SwqosConfig::Jito("your uuid".to_string(), SwqosRegion::Frankfurt, None), - SwqosConfig::NextBlock("your api_token".to_string(), SwqosRegion::Frankfurt, None), SwqosConfig::Bloxroute("your api_token".to_string(), SwqosRegion::Frankfurt, None), SwqosConfig::ZeroSlot("your api_token".to_string(), SwqosRegion::Frankfurt, None), SwqosConfig::Temporal("your api_token".to_string(), SwqosRegion::Frankfurt, None), @@ -233,7 +232,7 @@ let jito_config = SwqosConfig::Jito( ); // 使用默认区域端点(第三个参数为 None) -let nextblock_config = SwqosConfig::NextBlock( +let bloxroute_config = SwqosConfig::Bloxroute( "your_api_token".to_string(), SwqosRegion::NewYork, // 将使用该区域的默认端点 None // 没有自定义 URL,使用 SwqosRegion @@ -273,7 +272,6 @@ let middleware_manager = MiddlewareManager::new() 可以通过官网申请密钥:[社区官网](https://fnzero.dev/swqos) - **Jito**: 高性能区块空间 -- **NextBlock**: 快速交易执行 - **ZeroSlot**: 零延迟交易 - **Temporal**: 时间敏感交易 - **Bloxroute**: 区块链网络加速 diff --git a/examples/trading_client/src/main.rs b/examples/trading_client/src/main.rs index 16d3b5d..8939846 100644 --- a/examples/trading_client/src/main.rs +++ b/examples/trading_client/src/main.rs @@ -25,7 +25,6 @@ async fn create_solana_trade_client() -> AnyResult { let swqos_configs: Vec = vec![ SwqosConfig::Default(rpc_url.clone()), SwqosConfig::Jito("your uuid".to_string(), SwqosRegion::Frankfurt, None), - SwqosConfig::NextBlock("your api_token".to_string(), SwqosRegion::Frankfurt, None), SwqosConfig::Bloxroute("your api_token".to_string(), SwqosRegion::Frankfurt, None), SwqosConfig::ZeroSlot("your api_token".to_string(), SwqosRegion::Frankfurt, None), SwqosConfig::Temporal("your api_token".to_string(), SwqosRegion::Frankfurt, None), diff --git a/src/lib.rs b/src/lib.rs index f7a5dd8..a707866 100755 --- a/src/lib.rs +++ b/src/lib.rs @@ -198,6 +198,11 @@ impl TradingClient { let mut swqos_clients: Vec> = vec![]; for swqos in swqos_configs { + // Check blacklist, skip disabled providers + if swqos.is_blacklisted() { + eprintln!("\u{26a0}\u{fe0f} SWQOS {:?} is blacklisted, skipping", swqos.swqos_type()); + continue; + } match SwqosConfig::get_swqos_client(rpc_url.clone(), commitment.clone(), swqos.clone()) .await { diff --git a/src/swqos/mod.rs b/src/swqos/mod.rs index 4e36907..cb358ac 100755 --- a/src/swqos/mod.rs +++ b/src/swqos/mod.rs @@ -58,6 +58,13 @@ lazy_static::lazy_static! { static ref TIP_ACCOUNT_CACHE: RwLock> = RwLock::new(Vec::new()); } +/// SWQOS provider blacklist configuration +/// Providers added here will be disabled even if configured by user +/// To enable a provider, remove it from this list +pub const SWQOS_BLACKLIST: &[SwqosType] = &[ + SwqosType::NextBlock, // NextBlock is disabled by default +]; + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum TradeType { Create, @@ -187,6 +194,11 @@ impl SwqosConfig { } } + /// Check if current config is in the blacklist + pub fn is_blacklisted(&self) -> bool { + SWQOS_BLACKLIST.contains(&self.swqos_type()) + } + pub fn get_endpoint(swqos_type: SwqosType, region: SwqosRegion, url: Option) -> String { if let Some(custom_url) = url { return custom_url;