pub fn add_tx(
tx: &Transaction,
tx_blob: &Vec<u8>,
tx_hash: &TxHash,
block_height: &BlockHeight,
tables: &mut impl TablesMut,
) -> Result<TxId, RuntimeError>
Expand description
Add a Transaction
(and related data) to the database.
The block_height
is the block that this tx
belongs to.
Note that the caller’s input is trusted implicitly and no checks
are done (in this function) whether the block_height
is correct or not.
§⚠️ 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:
- This effect (incomplete database mutation) is what is desired, or that…
- …the other tables will also be mutated to a correct state
§Notes
This function is different from other sub-functions and slightly more similar to
add_block()
in that it calls other sub-functions.
This function calls:
Thus, after add_tx
, those values (outputs and key images)
will be added to database tables as well.
§Panics
This function will panic if:
block.height > u32::MAX
(not normally possible)
§Errors
This function returns RuntimeError::KeyNotFound
if the input (if applicable) doesn’t exist or other RuntimeError
’s on database errors.