Function sp_io::offchain::local_storage_compare_and_set
source · pub fn local_storage_compare_and_set(
kind: StorageKind,
key: &[u8],
old_value: Option<Vec<u8>>,
new_value: &[u8],
) -> bool
Expand description
Sets a value in the local storage if it matches current value.
Since multiple offchain workers may be running concurrently, to prevent data races use CAS to coordinate between them.
Returns true
if the value has been set, false
otherwise.
Note this storage is not part of the consensus, it’s only accessible by offchain worker tasks running on the same machine. It IS persisted between runs.