use super::super::inner::action;
use crate::handles::{DbRead, DbWrite};
use crate::kind::Dht;
use crate::models::dht::AgentActivityItem;
use holo_hash::{ActionHash, AgentPubKey, AnyLinkableHash, EntryHash};
use holochain_integrity_types::dht_v2::RecordValidity;
use holochain_zome_types::dht_v2::SignedActionHashed;
impl DbWrite<Dht> {
pub async fn insert_action(
&self,
action: &SignedActionHashed,
record_validity: Option<RecordValidity>,
) -> sqlx::Result<()> {
action::insert_action(self.pool(), action, record_validity).await
}
}
impl DbRead<Dht> {
pub async fn get_action(&self, hash: ActionHash) -> sqlx::Result<Option<SignedActionHashed>> {
action::get_action(self.pool(), hash).await
}
pub async fn get_actions_by_author(
&self,
author: AgentPubKey,
) -> sqlx::Result<Vec<SignedActionHashed>> {
action::get_actions_by_author(self.pool(), author).await
}
pub async fn count_author_actions_capped(
&self,
author: &AgentPubKey,
cap: i64,
) -> sqlx::Result<i64> {
action::count_author_actions_capped(self.pool(), author, cap).await
}
pub async fn get_agent_activity(
&self,
author: AgentPubKey,
include_entries: bool,
) -> sqlx::Result<Vec<AgentActivityItem>> {
action::get_agent_activity(self.pool(), &author, include_entries).await
}
pub async fn get_filtered_agent_activity(
&self,
author: AgentPubKey,
chain_top_seq: u32,
until_seq: Option<u32>,
) -> sqlx::Result<Vec<SignedActionHashed>> {
action::get_filtered_agent_activity(self.pool(), &author, chain_top_seq, until_seq).await
}
pub async fn get_action_seq_and_timestamp(
&self,
author: AgentPubKey,
action_hash: ActionHash,
) -> sqlx::Result<Option<(u32, holochain_timestamp::Timestamp)>> {
action::get_action_seq_and_timestamp(self.pool(), &author, &action_hash).await
}
pub async fn get_actions_by_prev_hash(
&self,
prev_hash: &ActionHash,
exclude_hash: &ActionHash,
) -> sqlx::Result<Vec<SignedActionHashed>> {
action::get_actions_by_prev_hash(self.pool(), prev_hash, exclude_hash).await
}
pub async fn get_create_actions_for_entry(
&self,
entry_hash: &EntryHash,
author: Option<&AgentPubKey>,
validation_status: RecordValidity,
) -> sqlx::Result<Vec<SignedActionHashed>> {
action::get_create_actions_for_entry(self.pool(), entry_hash, author, validation_status)
.await
}
pub async fn get_delete_actions_for_entry(
&self,
entry_hash: &EntryHash,
) -> sqlx::Result<Vec<SignedActionHashed>> {
action::get_delete_actions_for_entry(self.pool(), entry_hash).await
}
pub async fn get_update_actions_for_entry(
&self,
entry_hash: &EntryHash,
) -> sqlx::Result<Vec<SignedActionHashed>> {
action::get_update_actions_for_entry(self.pool(), entry_hash).await
}
pub async fn get_live_entry_creates(
&self,
entry_hash: &EntryHash,
author: Option<&AgentPubKey>,
) -> sqlx::Result<Vec<SignedActionHashed>> {
action::get_live_entry_creates(self.pool(), entry_hash, author).await
}
pub async fn get_delete_actions_for_record(
&self,
record_action_hash: &ActionHash,
) -> sqlx::Result<Vec<SignedActionHashed>> {
action::get_delete_actions_for_record(self.pool(), record_action_hash).await
}
pub async fn get_update_actions_for_record(
&self,
record_action_hash: &ActionHash,
) -> sqlx::Result<Vec<SignedActionHashed>> {
action::get_update_actions_for_record(self.pool(), record_action_hash).await
}
pub async fn get_live_link_actions(
&self,
base: &AnyLinkableHash,
) -> sqlx::Result<Vec<SignedActionHashed>> {
action::get_live_link_actions(self.pool(), base).await
}
pub async fn get_link_create_actions(
&self,
base: &AnyLinkableHash,
) -> sqlx::Result<Vec<SignedActionHashed>> {
action::get_link_create_actions(self.pool(), base).await
}
pub async fn get_delete_link_actions(
&self,
create_link_hash: &ActionHash,
) -> sqlx::Result<Vec<SignedActionHashed>> {
action::get_delete_link_actions(self.pool(), create_link_hash).await
}
pub async fn get_authority_link_creates(
&self,
base: &AnyLinkableHash,
) -> sqlx::Result<Vec<(SignedActionHashed, RecordValidity)>> {
action::get_authority_link_creates(self.pool(), base).await
}
pub async fn get_authority_delete_links(
&self,
base: &AnyLinkableHash,
) -> sqlx::Result<Vec<(SignedActionHashed, RecordValidity)>> {
action::get_authority_delete_links(self.pool(), base).await
}
pub async fn get_authority_store_record(
&self,
action_hash: &ActionHash,
) -> sqlx::Result<Option<(SignedActionHashed, RecordValidity)>> {
action::get_authority_store_record(self.pool(), action_hash).await
}
pub async fn get_authority_deletes_for_record(
&self,
record_action_hash: &ActionHash,
) -> sqlx::Result<Vec<(SignedActionHashed, RecordValidity)>> {
action::get_authority_deletes_for_record(self.pool(), record_action_hash).await
}
pub async fn get_authority_updates_for_record(
&self,
record_action_hash: &ActionHash,
) -> sqlx::Result<Vec<(SignedActionHashed, RecordValidity)>> {
action::get_authority_updates_for_record(self.pool(), record_action_hash).await
}
pub async fn get_authority_entry_creates(
&self,
entry_hash: &EntryHash,
) -> sqlx::Result<Vec<(SignedActionHashed, RecordValidity)>> {
action::get_authority_entry_creates(self.pool(), entry_hash).await
}
pub async fn get_authority_deletes_for_entry(
&self,
entry_hash: &EntryHash,
) -> sqlx::Result<Vec<(SignedActionHashed, RecordValidity)>> {
action::get_authority_deletes_for_entry(self.pool(), entry_hash).await
}
pub async fn get_authority_updates_for_entry(
&self,
entry_hash: &EntryHash,
) -> sqlx::Result<Vec<(SignedActionHashed, RecordValidity)>> {
action::get_authority_updates_for_entry(self.pool(), entry_hash).await
}
}