//! [Keep db flowchart](https://raw.githubusercontent.com/moondance-labs/tanssi/master/docs/keep_db_flowchart.png)
/// Messages used to control the `ContainerChainSpawner`. This is needed because one of the fields
.map_err(|e| format!("failed to create container chain chain spec from on chain genesis data: {}", e))?;
// Create a new cli config because otherwise the tasks spawned in `open_and_maybe_delete_db` don't stop
// Dropping is not enough because there is some background process that keeps the database open,
log::error!("Essential task failed in container chain {} task manager. Shutting down container chain service", container_chain_para_id);
log::error!("Unexpected shutdown in container chain {} task manager. Shutting down container chain service", container_chain_para_id);
/// Returns the database path for the container chain, can be used with `wait_for_paritydb_lock`
/// to ensure that the container chain has fully stopped. The database path can be `None` if the
// Ignore orchestrator_para_id because it is handled in a special way, as it does not need to
// Force restart of new assigned container chain: if it was running before it was in "syncing mode",
// Handle edge case of going from (2000, 2001) to (2001, 2000). In that case we must restart both chains,
/// We want to use warp sync unless the db still exists, or the block number is 0 (because of a warp sync bug in that case).
/// The reason is that warp sync doesn't work if a database already exists, it falls back to full sync instead.
/// Start a container chain using `new_partial` and check if the database is valid. If not, delete the db.
/// The caller may need to wait a few seconds before trying to start the same container chain again, to
// TODO: instead of waiting, we could also return Weak references to the components `temp_cli.backend`
// and `temp_cli.client`, and then the caller would only need to check if the reference counts are 0.
/// So we use `delete_empty_folders_recursive` to try to remove the parent folders as well, but only
/// Removes all empty folders in `path`, recursively. Then, if `path` is empty, it removes it as well.
/// <https://github.com/paritytech/parity-db/blob/2b6820e310a08678d4540c044f41a93d87343ac8/src/db.rs#L215>
let db_path = PathBuf::from("/tmp/zombienet/Collator2002-01/data/containers/chains/simple_container_2002/paritydb/full-container-2002");