pub(crate) fn maybe_commit_effects(
    commit: bool,
    changeset: ChangeSet,
    events: Vec<Event>,
    state: &OnDiskStateView,
) -> Result<()> {
    // similar to explain effects, all module publishing happens via save_modules(), so effects
    // shouldn't contain modules
    if commit {
        for (addr, account) in changeset.into_inner() {
            for (struct_tag, blob_opt) in account.into_resources() {
                match blob_opt {
                    Some(blob) => state.save_resource(addr, struct_tag, &blob)?,
                    None => state.delete_resource(addr, struct_tag)?,
                }
            }
        }

        for (event_key, event_sequence_number, event_type, event_data) in events {
            state.save_event(&event_key, event_sequence_number, event_type, event_data)?
        }
    } else if !(changeset.resources().next().is_none() && events.is_empty()) {
        println!("Discarding changes; re-run without --dry-run if you would like to keep them.")
    }

    Ok(())
}
/// Commit the resources and events modified by a transaction to disk
Commit the resources and events modified by a transaction to disk
Commit the resources and events modified by a transaction to disk
pub(crate) fn maybe_commit_effects(
    commit: bool,
    changeset: ChangeSet,
    events: Vec<Event>,
    state: &OnDiskStateView,
) -> Result<()> {
    // similar to explain effects, all module publishing happens via save_modules(), so effects
    // shouldn't contain modules
    if commit {
        for (addr, account) in changeset.into_inner() {
            for (struct_tag, blob_opt) in account.into_resources() {
                match blob_opt {
                    Some(blob) => state.save_resource(addr, struct_tag, &blob)?,
                    None => state.delete_resource(addr, struct_tag)?,
                }
            }
        }
        for (event_key, event_sequence_number, event_type, event_data) in events {
            state.save_event(&event_key, event_sequence_number, event_type, event_data)?
        }
    } else if !(changeset.resources().next().is_none() && events.is_empty()) {
        println!("Discarding changes; re-run without --dry-run if you would like to keep them.")
    }
    Ok(())
}
pub ( crate ) fn maybe_commit_effects ( commit : bool , changeset : ChangeSet , events : Vec < Event > , state : & OnDiskStateView , ) -> Result < ( ) > { // similar to explain effects, all module publishing happens via save_modules(), so effects // shouldn't contain modules if commit { for ( addr , account ) in changeset . into_inner ( ) { for ( struct_tag , blob_opt ) in account . into_resources ( ) { match blob_opt { Some ( blob ) => state . save_resource ( addr , struct_tag , & blob ) ? , None => state . delete_resource ( addr , struct_tag ) ? , } } } for ( event_key , event_sequence_number , event_type , event_data ) in events { state . save_event ( & event_key , event_sequence_number , event_type , event_data ) ? } } else if ! ( changeset . resources ( ) . next ( ) . is_none ( ) && events . is_empty ( ) ) { println ! ( " " ) } Ok ( ( ) ) }
Commit the resources and events modified by a transaction to disk
Commit the resources and events modified by a transaction to disk
commit
bool
changeset
ChangeSet
events
Vec<Event>
state
&OnDiskStateView