Merge commit 'de8c55e599fa58e35e3f3dc68437f8ae4712d4ba'
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
|
||||
pub fn print_all_strategies(&self) {
|
||||
|
||||
+19
-5
@@ -133,18 +133,32 @@ pub async fn poll_transaction_confirmation(
|
||||
let ui_err = meta.err.unwrap();
|
||||
let tx_err: TransactionError =
|
||||
serde_json::from_value(serde_json::to_value(&ui_err)?)?;
|
||||
let mut code = 500;
|
||||
|
||||
// 直接使用Solana原生的InstructionError中的错误码
|
||||
let mut code = 0u32;
|
||||
let mut index = None;
|
||||
match &tx_err {
|
||||
TransactionError::InstructionError(i, i_error) => {
|
||||
match i_error {
|
||||
solana_sdk::instruction::InstructionError::Custom(c) => code = *c,
|
||||
_ => {}
|
||||
}
|
||||
// 直接匹配所有InstructionError类型,Custom也是其中之一
|
||||
code = match i_error {
|
||||
solana_sdk::instruction::InstructionError::Custom(c) => *c,
|
||||
solana_sdk::instruction::InstructionError::GenericError => 1,
|
||||
solana_sdk::instruction::InstructionError::InvalidArgument => 2,
|
||||
solana_sdk::instruction::InstructionError::InvalidInstructionData => 3,
|
||||
solana_sdk::instruction::InstructionError::InvalidAccountData => 4,
|
||||
solana_sdk::instruction::InstructionError::AccountDataTooSmall => 5,
|
||||
solana_sdk::instruction::InstructionError::InsufficientFunds => 6,
|
||||
solana_sdk::instruction::InstructionError::IncorrectProgramId => 7,
|
||||
solana_sdk::instruction::InstructionError::MissingRequiredSignature => 8,
|
||||
solana_sdk::instruction::InstructionError::AccountAlreadyInitialized => 9,
|
||||
solana_sdk::instruction::InstructionError::UninitializedAccount => 10,
|
||||
_ => 999, // 其他未知错误
|
||||
};
|
||||
index = Some(*i);
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
||||
return Err(anyhow::Error::new(TradeError {
|
||||
code: code,
|
||||
message: format!("{} {:?}", tx_err, error_msg),
|
||||
|
||||
Reference in New Issue
Block a user