mirror of
https://github.com/RoboSats/taptrade-core.git
synced 2025-07-23 11:13:17 +00:00
add min bond amount to monitoring, add chunking of monitored bonds for testmempoolaccept call
This commit is contained in:
@ -49,8 +49,13 @@ pub async fn monitor_bonds(coordinator: Arc<Coordinator>) -> Result<()> {
|
|||||||
let coordinator_wallet = Arc::clone(&coordinator.coordinator_wallet);
|
let coordinator_wallet = Arc::clone(&coordinator.coordinator_wallet);
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
|
// sleep for a while
|
||||||
|
tokio::time::sleep(tokio::time::Duration::from_secs(15)).await;
|
||||||
// fetch all bonds
|
// fetch all bonds
|
||||||
let bonds = Arc::new(coordinator_db.fetch_all_bonds().await?);
|
let bonds = Arc::new(coordinator_db.fetch_all_bonds().await?);
|
||||||
|
if bonds.is_empty() {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
let validation_results = coordinator_wallet
|
let validation_results = coordinator_wallet
|
||||||
.validate_bonds(Arc::clone(&bonds))
|
.validate_bonds(Arc::clone(&bonds))
|
||||||
.await?;
|
.await?;
|
||||||
@ -73,8 +78,6 @@ pub async fn monitor_bonds(coordinator: Arc<Coordinator>) -> Result<()> {
|
|||||||
_ => Err(anyhow!("Invalid PUNISHMENT_ENABLED env var"))?,
|
_ => Err(anyhow!("Invalid PUNISHMENT_ENABLED env var"))?,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// sleep for a while
|
|
||||||
tokio::time::sleep(tokio::time::Duration::from_secs(15)).await;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -215,12 +215,22 @@ fn test_mempool_accept_bonds(
|
|||||||
) -> Result<HashMap<Vec<u8>, (MonitoringBond, anyhow::Error)>> {
|
) -> Result<HashMap<Vec<u8>, (MonitoringBond, anyhow::Error)>> {
|
||||||
let mut invalid_bonds: HashMap<Vec<u8>, (MonitoringBond, anyhow::Error)> = HashMap::new();
|
let mut invalid_bonds: HashMap<Vec<u8>, (MonitoringBond, anyhow::Error)> = HashMap::new();
|
||||||
|
|
||||||
let raw_bonds: Vec<String> = bonds
|
let raw_bonds: Vec<Vec<String>> = bonds
|
||||||
.iter()
|
.iter()
|
||||||
.map(|bond| bond.bond_tx_hex.clone().raw_hex()) // Assuming `raw_hex()` returns a String or &str
|
.map(|bond| bond.bond_tx_hex.clone().raw_hex())
|
||||||
|
.collect::<Vec<String>>()
|
||||||
|
.chunks(25) // Assuming `raw_hex()` returns a String or &str
|
||||||
|
.map(|chunk| chunk.to_vec())
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
let test_mempool_accept_res = json_rpc_client.deref().test_mempool_accept(&raw_bonds)?;
|
let mut test_mempool_accept_res = Vec::new();
|
||||||
|
for raw_bonds_subvec in raw_bonds {
|
||||||
|
test_mempool_accept_res.extend(
|
||||||
|
json_rpc_client
|
||||||
|
.deref()
|
||||||
|
.test_mempool_accept(&raw_bonds_subvec)?,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
for res in test_mempool_accept_res {
|
for res in test_mempool_accept_res {
|
||||||
if !res.allowed {
|
if !res.allowed {
|
||||||
|
Reference in New Issue
Block a user