add min bond amount to monitoring, add chunking of monitored bonds for testmempoolaccept call

This commit is contained in:
f321x
2024-07-15 18:29:30 +02:00
parent 4ed3d9597a
commit e73b879546
2 changed files with 18 additions and 5 deletions

View File

@ -49,8 +49,13 @@ pub async fn monitor_bonds(coordinator: Arc<Coordinator>) -> Result<()> {
let coordinator_wallet = Arc::clone(&coordinator.coordinator_wallet);
loop {
// sleep for a while
tokio::time::sleep(tokio::time::Duration::from_secs(15)).await;
// fetch all bonds
let bonds = Arc::new(coordinator_db.fetch_all_bonds().await?);
if bonds.is_empty() {
continue;
}
let validation_results = coordinator_wallet
.validate_bonds(Arc::clone(&bonds))
.await?;
@ -73,8 +78,6 @@ pub async fn monitor_bonds(coordinator: Arc<Coordinator>) -> Result<()> {
_ => Err(anyhow!("Invalid PUNISHMENT_ENABLED env var"))?,
}
}
// sleep for a while
tokio::time::sleep(tokio::time::Duration::from_secs(15)).await;
}
}

View File

@ -215,12 +215,22 @@ fn test_mempool_accept_bonds(
) -> Result<HashMap<Vec<u8>, (MonitoringBond, anyhow::Error)>> {
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()
.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();
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 {
if !res.allowed {