batch mm txs
This commit is contained in:
parent
be148301bb
commit
465e628a64
|
@ -3241,6 +3241,7 @@ dependencies = [
|
|||
"async-channel",
|
||||
"async-std",
|
||||
"async-trait",
|
||||
"bincode",
|
||||
"borsh 0.9.3",
|
||||
"bytemuck",
|
||||
"chrono",
|
||||
|
|
|
@ -60,6 +60,7 @@ solana-program = "1.9.17"
|
|||
mango = { git = "https://github.com/blockworks-foundation/mango-v3.git", tag = "v3.6.0", default-features = false }
|
||||
mango-common = { git = "https://github.com/blockworks-foundation/mango-v3.git", tag = "v3.6.0" }
|
||||
mango-feeds-connector = { git = "https://github.com/blockworks-foundation/mango-feeds.git", branch = "ckamm/solana-versions2", default-features = false, features = ["solana-1-15"] }
|
||||
bincode = "1.3.3"
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
targets = ["x86_64-unknown-linux-gnu"]
|
||||
|
|
|
@ -170,6 +170,7 @@ pub async fn send_mm_transactions(
|
|||
100,
|
||||
1000,
|
||||
);
|
||||
let mut batch_to_send = Vec::with_capacity(perp_market_caches.len());
|
||||
for (i, c) in perp_market_caches.iter().enumerate() {
|
||||
let prioritization_fee = prioritization_fee_by_market[i];
|
||||
let mut tx = create_ask_bid_transaction(
|
||||
|
@ -182,7 +183,7 @@ pub async fn send_mm_transactions(
|
|||
let recent_blockhash = *blockhash.read().await;
|
||||
tx.sign(&[mango_account_signer], recent_blockhash);
|
||||
|
||||
let tx_send_record = TransactionSendRecord {
|
||||
let record = TransactionSendRecord {
|
||||
signature: tx.signatures[0],
|
||||
sent_at: Utc::now(),
|
||||
sent_slot: slot.load(Ordering::Acquire),
|
||||
|
@ -191,9 +192,12 @@ pub async fn send_mm_transactions(
|
|||
priority_fees: prioritization_fee,
|
||||
keeper_instruction: None,
|
||||
};
|
||||
if !tpu_manager.send_transaction(&tx, tx_send_record).await {
|
||||
println!("sending failed on tpu client");
|
||||
}
|
||||
batch_to_send.push((tx, record));
|
||||
}
|
||||
|
||||
|
||||
if !tpu_manager.send_transaction_batch(&batch_to_send).await {
|
||||
println!("sending failed on tpu client");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
use bincode::serialize;
|
||||
use log::{info, warn};
|
||||
use solana_client::nonblocking::rpc_client::RpcClient;
|
||||
use solana_client::{connection_cache::ConnectionCache, nonblocking::tpu_client::TpuClient};
|
||||
|
@ -142,4 +143,30 @@ impl TpuManager {
|
|||
|
||||
tpu_client.send_transaction(transaction).await
|
||||
}
|
||||
|
||||
pub async fn send_transaction_batch(
|
||||
&self,
|
||||
batch: &Vec<(solana_sdk::transaction::Transaction, TransactionSendRecord)>,
|
||||
) -> bool {
|
||||
let tpu_client = self.get_tpu_client().await;
|
||||
|
||||
|
||||
for (tx, record) in batch {
|
||||
|
||||
self.stats
|
||||
.inc_send(&record.keeper_instruction);
|
||||
|
||||
let tx_sent_record = self.tx_send_record.clone();
|
||||
let sent = tx_sent_record.send(record.clone());
|
||||
if sent.is_err() {
|
||||
warn!(
|
||||
"sending error on channel : {}",
|
||||
sent.err().unwrap().to_string()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
tpu_client.try_send_wire_transaction_batch(batch.iter().map(|(tx, _)| serialize(tx).expect("serialization should succeed")).collect()).await.is_ok()
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue