feat(swqos): align endpoint tables with SwqosRegion and document fallbacks

- Extend SWQOS regional constants to 10 entries (Dublin, Singapore, Default)
  so indices match SwqosRegion 0..9 everywhere
- Document geographic nearest-fill among published PoPs; call out Default and
  single-PoP provider constraints in comments
- Fix Node1 QUIC Default endpoint to match HTTP; tune ZeroSlot/Blox/Speedlanding
  regional mappings where a closer published PoP exists
- Add unit tests for table length and Astralane/Node1 cross-table consistency
- Update SwqosRegion rustdoc, README, and trading_client example accordingly

Made-with: Cursor
This commit is contained in:
0xfnzero
2026-04-14 02:13:42 +08:00
parent a391539000
commit 06ef2fed84
8 changed files with 333 additions and 174 deletions
+14 -14
View File
@@ -48,7 +48,7 @@
- [⚡ 交易参数](#-交易参数)
- [📊 使用示例汇总表格](#-使用示例汇总表格)
- [⚙️ SWQoS 服务配置说明](#-swqos-服务配置说明)
- [Astralane QUIC(低延迟](#astralane-quic低延迟)
- [AstralaneBinary / Plain / QUIC](#astralanebinary--plain--quic)
- [🔧 中间件系统说明](#-中间件系统说明)
- [🔍 地址查找表](#-地址查找表)
- [🔍 Nonce 缓存](#-nonce-缓存)
@@ -131,13 +131,13 @@ let swqos_configs: Vec<SwqosConfig> = vec![
SwqosConfig::Default(rpc_url.clone()),
SwqosConfig::Jito("your uuid".to_string(), SwqosRegion::Frankfurt, None),
SwqosConfig::Bloxroute("your api_token".to_string(), SwqosRegion::Frankfurt, None),
// Astralane:第4个参数 None 为 HTTPSome(SwqosTransport::Quic) 为 QUIC;同一 API key
SwqosConfig::Astralane("your_astralane_api_key".to_string(), SwqosRegion::Frankfurt, None, None), // HTTP
// Astralane:第4个参数为 AstralaneTransport — Binary(默认)、Plain/iris)或 Quic
SwqosConfig::Astralane("your_astralane_api_key".to_string(), SwqosRegion::Frankfurt, None, None), // Binary /irisb
SwqosConfig::Astralane(
"your_astralane_api_key".to_string(),
SwqosRegion::Frankfurt,
None,
Some(SwqosTransport::Quic),
Some(AstralaneTransport::Quic),
), // QUIC
];
// 创建 TradeConfig 实例
@@ -147,7 +147,7 @@ let trade_config = TradeConfig::builder(rpc_url, swqos_configs, commitment)
// .log_enabled(true) // 默认: true - SDK 计时 / SWQOS 日志
// .check_min_tip(false) // 默认: false - 过滤低于最低小费的 SWQOS
// .swqos_cores_from_end(false) // 默认: false - 将 SWQOS 绑定到末尾 N 个 CPU 核心
// .mev_protection(false) // 默认: false - MEV 保护Astralane 端口 9000 / BlockRazor sandwichMitigation
// .mev_protection(false) // 默认: false - MEVAstralane QUIC :9000 或 HTTP mev-protect / BlockRazor
.build();
// 创建 TradingClient
@@ -279,28 +279,28 @@ let bloxroute_config = SwqosConfig::Bloxroute(
当使用多个MEV服务时,需要使用`Durable Nonce`。你需要使用`fetch_nonce_info`函数获取最新的`nonce`值,并在交易的时候将`durable_nonce`填入交易参数。
#### Astralane QUIC(低延迟
#### AstralaneBinary / Plain / QUIC
Astralane 支持 **HTTP****QUIC** 两种传输方式。QUIC 可减少连接开销,降低提交延迟。使用 QUIC 时,将 `SwqosConfig::Astralane`第四个参数设为 `Some(SwqosTransport::Quic)`。Astralane 的 QUIC 服务使用**单一端点**(无分区域端点),选 QUIC 时 SDK 会忽略 `region` 与可选自定义 URL;为与其他 SWQoS 配置一致,可传入相同 region
Astralane 支持 **Binary** HTTP`/irisb`)、**Plain** HTTP`/iris`)与 **QUIC**`host:7000`,全局 `mev_protection` 为 true 时用 `:9000`)。第四个参数`Some(AstralaneTransport::Plain)``Some(AstralaneTransport::Quic)`,或 `None` 表示 **Binary**(默认)。全局 `mev_protection` 会在 HTTP 上附加 `mev-protect=true`,或为 QUIC 选择 9000 端口
```rust
use sol_trade_sdk::{SwqosConfig, SwqosRegion, SwqosTransport};
use sol_trade_sdk::{SwqosConfig, SwqosRegion, AstralaneTransport};
// Astralane 使用 QUIC(低延迟);region 会被忽略(QUIC 单一端点)
let swqos_configs: Vec<SwqosConfig> = vec![
SwqosConfig::Default(rpc_url.clone()),
SwqosConfig::Astralane(
"your_astralane_api_key".to_string(),
SwqosRegion::Frankfurt, // 与其他服务一致即可;QUIC 时会被忽略
SwqosRegion::Frankfurt,
None,
Some(SwqosTransport::Quic),
Some(AstralaneTransport::Quic),
),
];
// 然后照常使用 swqos_configs 创建 TradeConfig / TradingClient
```
- **HTTP**(默认):第四个参数为 `None``Some(SwqosTransport::Http)`region 与可选自定义 URL 生效
- **QUIC**:第四个参数为 `Some(SwqosTransport::Quic)`;SDK 使用单一 QUIC 端点并忽略 region。与 HTTP 使用同一 API key
- **Binary**(默认):`None``Some(AstralaneTransport::Binary)``/irisb`bincode 正文
- **Plain**`Some(AstralaneTransport::Plain)``/iris`
- **QUIC**`Some(AstralaneTransport::Quic)` — 按区域的 `host:7000` / `:9000`MEV);同一 API key。
---
@@ -363,7 +363,7 @@ SDK 不会在每次卖出时通过 RPC 拉取 creator_vault(以避免延迟)
- **FlashBlock**: 高速交易执行,支持 API 密钥认证
- **BlockRazor**: 高速交易执行,支持 API 密钥认证
- **Node1**: 高速交易执行,支持 API 密钥认证
- **Astralane**: 区块链网络加速(支持 HTTP 与 QUIC,见上方 [Astralane QUIC](#astralane-quic低延迟)
- **Astralane**: 区块链网络加速(Binary/Plain HTTP 与 QUIC,见 [Astralane](#astralanebinary--plain--quic)
## 📁 项目结构