Skip to content

Commit

Permalink
fix: adding image in ocw storage recipe
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmychu0807 committed May 15, 2020
1 parent a4ccaed commit 98a974f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions text/3-entrees/off-chain-workers/storage.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ Remember we mentioned that off-chain workers (short for **ocw** below) cannot wr

Fortunately, there is also a local storage that persist across runs in off-chain workers. Storage is local within off-chain workers and not passed within network. Storage of off-chain workers is persisted across runs of off-chain workers and blockchain re-organizations.

Off-chain workers are asynchronously run during block import. Since ocws are not limited how long they run, at any single instance there could be multiple ocws running, being initiated by the previous block imports. See diagram below.
Off-chain workers are asynchronously run during block import. Since ocws are not limited by how long they run, at any single instance there could be multiple ocws running, being initiated by previous block imports. See diagram below.

[!TK: insert image of multiple ocw from previous block imports].
![More than one off-chain workers at a single instance](/img/multiple-ocws.png)

The storage has a similar API usage as on-chain [`StorageValue`](/2-appetizers/2-storage-values.html) with `get`, `set`, and `mutate`. `mutate` is using a [`compare-and-set`](https://en.wikipedia.org/wiki/Compare-and-swap) pattern. It compares the contents of a memory location with a given value and, only if they are the same, modifies the contents of that memory location to a new given value. This is done as a single atomic operation. The atomicity guarantees that the new value is calculated based on up-to-date information; if the value had been updated by another thread in the meantime, the write would fail.

Expand Down
Binary file added text/img/multiple-ocws.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 98a974f

Please sign in to comment.