Skip to main content

TxWrite

Struct TxWrite 

Source
pub struct TxWrite<I: DatabaseIdentifier>(/* private fields */);
Expand description

A read-write database transaction handle.

Obtained from DbWrite::begin. Exposes the same operations as DbWrite and DbRead, but every operation runs on a single connection inside a real SQL transaction. Call TxWrite::commit to persist the changes, TxWrite::rollback to discard them, or drop without committing to roll back.

Implementations§

Source§

impl<I: DatabaseIdentifier> TxWrite<I>

Source

pub fn identifier(&self) -> &I

Get a reference to the database identifier.

Source

pub async fn commit(self) -> Result<()>

Commit the transaction, persisting all changes.

Source

pub async fn rollback(self) -> Result<()>

Roll back the transaction, discarding all changes.

Source§

impl TxWrite<Conductor>

Source

pub async fn set_conductor_tag(&mut self, tag: &str) -> Result<()>

Set the conductor tag.

Source

pub async fn put_app_interface( &mut self, port: i64, id: &str, model: &AppInterfaceModel, ) -> Result<()>

Insert or update an app interface.

Source

pub async fn put_signal_subscription( &mut self, interface_port: i64, interface_id: &str, app_id: &str, filters_blob: &[u8], ) -> Result<()>

Save a signal subscription for an app interface.

Source

pub async fn delete_signal_subscriptions( &mut self, interface_port: i64, interface_id: &str, ) -> Result<()>

Delete all signal subscriptions for an app interface.

Source

pub async fn delete_app_interface(&mut self, port: i64, id: &str) -> Result<()>

Delete an app interface.

Source

pub async fn put_installed_app( &mut self, app_id: &str, app: &InstalledAppCommon, status: &AppStatus, ) -> Result<()>

Insert or update an installed app.

Source

pub async fn delete_installed_app(&mut self, app_id: &str) -> Result<()>

Delete an installed app.

Source

pub async fn witness_nonce( &mut self, agent: AgentPubKey, nonce: Nonce256Bits, now: Timestamp, expires: Timestamp, ) -> Result<WitnessNonceResult, Error>

Witness a nonce (check if it’s fresh and record it).

Source

pub async fn block(&mut self, input: Block) -> Result<(), Error>

Append a block to the database.

Source§

impl TxWrite<Dht>

Source

pub async fn insert_action( &mut self, action: &SignedActionHashed, record_validity: Option<RecordValidity>, ) -> Result<()>

Insert an Action row, storing its signature and pre-computed hash.

Source§

impl TxWrite<Dht>

Source

pub async fn insert_cap_claim( &mut self, author: &AgentPubKey, tag: &str, grantor: &AgentPubKey, secret: &[u8], ) -> Result<()>

Source§

impl TxWrite<Dht>

Source

pub async fn insert_cap_grant( &mut self, action_hash: &ActionHash, cap_access: i64, tag: Option<&str>, ) -> Result<()>

Source§

impl TxWrite<Dht>

Source

pub async fn acquire_chain_lock( &mut self, author: &AgentPubKey, subject: &[u8], expires_at: Timestamp, now: Timestamp, ) -> Result<bool>

Try to acquire the chain lock for author. See the inner chain_lock::acquire_chain_lock for the full rule set. Returns true when the caller now holds the lock.

Source

pub async fn release_chain_lock(&mut self, author: &AgentPubKey) -> Result<()>

Source

pub async fn prune_expired_chain_locks(&mut self, now: Timestamp) -> Result<()>

Source§

impl TxWrite<Dht>

Source

pub async fn insert_chain_op(&mut self, op: InsertChainOp<'_>) -> Result<()>

Source§

impl TxWrite<Dht>

Source

pub async fn insert_chain_op_publish( &mut self, op_hash: &DhtOpHash, last_publish_time: Option<Timestamp>, receipts_complete: Option<bool>, ) -> Result<()>

Source§

impl TxWrite<Dht>

Source§

impl TxWrite<Dht>

Source

pub async fn insert_deleted_record_index( &mut self, action_hash: &ActionHash, deletes_action_hash: &ActionHash, deletes_entry_hash: &EntryHash, ) -> Result<()>

Source§

impl TxWrite<Dht>

Source

pub async fn insert_entry( &mut self, hash: &EntryHash, entry: &Entry, ) -> Result<()>

Source

pub async fn insert_private_entry( &mut self, hash: &EntryHash, author: &AgentPubKey, entry: &Entry, ) -> Result<()>

Source§

impl TxWrite<Dht>

Source

pub async fn insert_limbo_chain_op( &mut self, op: InsertLimboChainOp<'_>, ) -> Result<()>

Source

pub async fn delete_limbo_chain_op(&mut self, hash: DhtOpHash) -> Result<()>

Source§

impl TxWrite<Dht>

Source

pub async fn insert_limbo_warrant( &mut self, w: InsertLimboWarrant<'_>, ) -> Result<()>

Source

pub async fn delete_limbo_warrant(&mut self, hash: DhtOpHash) -> Result<()>

Source§

impl TxWrite<Dht>

Source§

impl TxWrite<Dht>

Source

pub async fn insert_updated_record_index( &mut self, action_hash: &ActionHash, original_action_hash: &ActionHash, original_entry_hash: &EntryHash, ) -> Result<()>

Source§

impl TxWrite<Dht>

Source

pub async fn insert_validation_receipt( &mut self, hash: &DhtOpHash, op_hash: &DhtOpHash, validators: &[u8], signature: &[u8], when_received: Timestamp, ) -> Result<()>

Source§

impl TxWrite<Dht>

Source

pub async fn insert_warrant(&mut self, w: InsertWarrant<'_>) -> Result<()>

Source§

impl TxWrite<Dht>

Source

pub async fn insert_warrant_publish( &mut self, warrant_hash: &DhtOpHash, last_publish_time: Option<Timestamp>, ) -> Result<()>

Source§

impl TxWrite<PeerMetaStore>

Source

pub async fn put( &mut self, peer_url: &str, meta_key: &str, meta_value: &[u8], expires_at_secs: Option<i64>, ) -> Result<()>

Insert or replace a peer metadata entry.

expires_at is seconds since the Unix epoch.

Source

pub async fn delete(&mut self, peer_url: &str, meta_key: &str) -> Result<()>

Delete a specific peer metadata entry.

Source

pub async fn prune(&mut self) -> Result<u64>

Delete all expired entries. Returns the number of rows removed.

Source§

impl TxWrite<Wasm>

Source

pub async fn put_wasm(&mut self, wasm: DnaWasmHashed) -> Result<()>

Store WASM bytecode.

Source

pub async fn put_dna_def( &mut self, agent: &AgentPubKey, dna_def: &DnaDef, ) -> Result<()>

Store a DNA definition and its associated zomes.

Within a TxWrite, this runs as a SAVEPOINT nested inside the outer transaction — it is atomic with the rest of the transaction.

Source

pub async fn put_entry_def( &mut self, key: Vec<u8>, entry_def: &EntryDef, ) -> Result<()>

Store an entry definition.

Trait Implementations§

Source§

impl<I: DatabaseIdentifier> AsMut<TxRead<I>> for TxWrite<I>

Mutably borrow a TxRead from a TxWrite.

Read operations on a transaction require &mut self (the transaction owns its connection), so reading through a TxWrite goes through AsMut rather than AsRef.

Source§

fn as_mut(&mut self) -> &mut TxRead<I>

Converts this type into a mutable reference of the (usually inferred) input type.
Source§

impl<I: DatabaseIdentifier> AsRef<TxRead<I>> for TxWrite<I>

Borrow a TxRead from a TxWrite.

Source§

fn as_ref(&self) -> &TxRead<I>

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<I: DatabaseIdentifier> From<TxWrite<I>> for TxRead<I>

Conversion from TxWrite to TxRead.

Source§

fn from(write: TxWrite<I>) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<I> Freeze for TxWrite<I>
where I: Freeze,

§

impl<I> !RefUnwindSafe for TxWrite<I>

§

impl<I> Send for TxWrite<I>
where I: Send,

§

impl<I> Sync for TxWrite<I>
where I: Sync,

§

impl<I> Unpin for TxWrite<I>
where I: Unpin,

§

impl<I> UnsafeUnpin for TxWrite<I>
where I: UnsafeUnpin,

§

impl<I> !UnwindSafe for TxWrite<I>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FutureExt for T

Source§

fn with_context(self, otel_cx: Context) -> WithContext<Self>

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
Source§

fn with_current_context(self) -> WithContext<Self>

Attaches the current Context to this type, returning a WithContext wrapper. Read more
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more