cuprate_blockchain::ops::tx

Function remove_tx

Source
pub fn remove_tx(
    tx_hash: &TxHash,
    tables: &mut impl TablesMut,
) -> Result<(TxId, Transaction), RuntimeError>
Expand description

Remove a transaction from the database with its TxHash.

This returns the TxId and TxBlob of the removed transaction.

§⚠️ Invariant ⚠️

This function mainly exists to be used internally by the parent function crate::ops::block::add_block.

add_block() makes sure all data related to the input is mutated, while this function does not, it specifically mutates particular tables.

This is usually undesired - although this function is still available to call directly.

When calling this function, ensure that either:

  1. This effect (incomplete database mutation) is what is desired, or that…
  2. …the other tables will also be mutated to a correct state

§Notes

As mentioned in add_tx, this function will call other sub-functions:

Thus, after remove_tx, those values (outputs and key images) will be remove from database tables as well.

§Errors

This function returns RuntimeError::KeyNotFound if the input (if applicable) doesn’t exist or other RuntimeError’s on database errors.