use super::super::inner::limbo_warrant::{self, InsertLimboWarrant};
use crate::handles::{DbRead, DbWrite};
use crate::kind::Dht;
use crate::models::dht::LimboWarrantRow;
use holo_hash::DhtOpHash;
use holochain_timestamp::Timestamp;
impl DbWrite<Dht> {
pub async fn insert_limbo_warrant(&self, w: InsertLimboWarrant<'_>) -> sqlx::Result<()> {
let mut tx = self.begin().await?;
limbo_warrant::insert_limbo_warrant(tx.conn_mut(), w).await?;
tx.commit().await?;
Ok(())
}
pub async fn delete_limbo_warrant(&self, hash: DhtOpHash) -> sqlx::Result<()> {
let mut tx = self.begin().await?;
limbo_warrant::delete_limbo_warrant(tx.conn_mut(), hash).await?;
tx.commit().await?;
Ok(())
}
pub async fn set_limbo_warrant_sys_validation_status(
&self,
hash: &DhtOpHash,
status: Option<i64>,
) -> sqlx::Result<u64> {
limbo_warrant::set_sys_validation_status(self.pool(), hash, status).await
}
pub async fn promote_limbo_warrant(
&self,
hash: &DhtOpHash,
when_integrated: Timestamp,
) -> sqlx::Result<bool> {
let mut tx = self.begin().await?;
let result =
limbo_warrant::promote_to_warrant(tx.conn_mut(), hash, when_integrated).await?;
tx.commit().await?;
Ok(result)
}
}
impl DbRead<Dht> {
pub async fn get_limbo_warrant(
&self,
hash: DhtOpHash,
) -> sqlx::Result<Option<LimboWarrantRow>> {
limbo_warrant::get_limbo_warrant(self.pool(), hash).await
}
pub async fn limbo_warrants_pending_sys_validation(
&self,
limit: u32,
) -> sqlx::Result<Vec<LimboWarrantRow>> {
limbo_warrant::limbo_warrants_pending_sys_validation(self.pool(), limit).await
}
pub async fn limbo_warrants_ready_for_integration(
&self,
limit: u32,
) -> sqlx::Result<Vec<LimboWarrantRow>> {
limbo_warrant::limbo_warrants_ready_for_integration(self.pool(), limit).await
}
}