Skip to content

Commit

Permalink
Update ASC trigger comment (#4740)
Browse files Browse the repository at this point in the history
* Update ASC trigger comment

* Add comment for ledger entry deletions

* fmt
  • Loading branch information
Leo-Besancon authored Aug 12, 2024
1 parent 77898f2 commit 07b093c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion massa-execution-worker/src/speculative_async_pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,5 +309,5 @@ impl SpeculativeAsyncPool {

/// Check in the ledger changes if a message trigger has been triggered
fn is_triggered(filter: &AsyncMessageTrigger, ledger_changes: &LedgerChanges) -> bool {
ledger_changes.has_changes(&filter.address, filter.datastore_key.clone())
ledger_changes.has_writes(&filter.address, filter.datastore_key.clone())
}
11 changes: 8 additions & 3 deletions massa-ledger-exports/src/ledger_changes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -835,16 +835,21 @@ impl LedgerChanges {
}
}

/// Tries to return whether there is a change on a given address in the ledger changes
/// and optionally if a datastore key modification also exists in the address's datastore.
/// Tries to return whether the ledger changes contain a write for the given address
/// and optionally if a datastore key write also exists in the address's datastore.
/// Notes:
/// - A ledger entry could be written to without any changes on the values associated,
/// for example if the value was changed multiple times in the same slot.
/// - This code assumes Delete cannot be shadowed by Set operations in the same slot, which may not be the case
/// when / if we allow full entry Delete given the current LedgerChanges::Delete handling. In that case, a rework may be necessary.
///
/// # Arguments
/// * `addr`: target address
/// * `key`: optional datastore key
///
/// # Returns
/// * true if the address and, optionally the datastore key, exists in the ledger changes
pub fn has_changes(&self, addr: &Address, key: Option<Vec<u8>>) -> bool {
pub fn has_writes(&self, addr: &Address, key: Option<Vec<u8>>) -> bool {
// Get the current changes being applied to the ledger entry associated to that address
match self.0.get(addr) {
// This ledger entry is being replaced by a new one:
Expand Down

0 comments on commit 07b093c

Please sign in to comment.