feat: add dynamic compute unit price update methods
添加动态优先费更新方法 ## 新增方法 - update_buy_cu_price(): 动态更新买入优先费 - update_sell_cu_price(): 动态更新卖出优先费 ## 功能 - 保持其他策略参数不变,仅更新 cu_price - 使用 RCU 模式确保线程安全 - 支持所有 SwqosType 和 GasFeeStrategyType ## 应用场景 - 根据交易金额动态调整优先费 - 实时优化 gas 费用策略 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -345,6 +345,34 @@ impl GasFeeStrategy {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// 动态更新买入优先费(保持其他参数不变)
|
||||||
|
/// Dynamically update buy compute unit price (keep other parameters unchanged)
|
||||||
|
pub fn update_buy_cu_price(&self, buy_cu_price: u64) {
|
||||||
|
self.strategies.rcu(|current_map| {
|
||||||
|
let mut new_map = (**current_map).clone();
|
||||||
|
for ((swqos_type, trade_type, strategy_type), value) in new_map.iter_mut() {
|
||||||
|
if *trade_type == TradeType::Buy {
|
||||||
|
value.cu_price = buy_cu_price;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Arc::new(new_map)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 动态更新卖出优先费(保持其他参数不变)
|
||||||
|
/// Dynamically update sell compute unit price (keep other parameters unchanged)
|
||||||
|
pub fn update_sell_cu_price(&self, sell_cu_price: u64) {
|
||||||
|
self.strategies.rcu(|current_map| {
|
||||||
|
let mut new_map = (**current_map).clone();
|
||||||
|
for ((swqos_type, trade_type, strategy_type), value) in new_map.iter_mut() {
|
||||||
|
if *trade_type == TradeType::Sell {
|
||||||
|
value.cu_price = sell_cu_price;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Arc::new(new_map)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/// 打印所有策略。
|
/// 打印所有策略。
|
||||||
/// Print all strategies
|
/// Print all strategies
|
||||||
pub fn print_all_strategies(&self) {
|
pub fn print_all_strategies(&self) {
|
||||||
|
|||||||
Reference in New Issue
Block a user