Skip to content
This repository has been archived by the owner on Aug 27, 2024. It is now read-only.

Commit

Permalink
Links and nitpicks
Browse files Browse the repository at this point in the history
  • Loading branch information
danforbes committed Dec 14, 2020
1 parent f4e9ac4 commit f0db1ab
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
20 changes: 14 additions & 6 deletions docs/knowledgebase/learn-substrate/off-chain-features.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,21 @@ easily access on-chain state for their computations.

Off-chain workers have access to extended APIs for communicating with the external world:

- Ability to submit transactions (either signed or unsigned) to the chain to publish computation
results.
- Ability to
[submit transactions](https://substrate.dev/rustdocs/v2.0.0/sp_runtime/offchain/trait.TransactionPool.html)
(either signed or unsigned) to the chain to publish computation results.
- A fully-featured HTTP client allowing the worker to access and fetch data from external services.
- Access to the local keystore to sign and verify statements or transactions.
- An additional, local key-value database shared between all off-chain workers.
- An additional, local
[key-value database](https://substrate.dev/rustdocs/v2.0.0/sp_runtime/offchain/trait.OffchainStorage.html)
shared between all off-chain workers.
- A secure, local entropy source for random number generation.
- Access to the node's precise local time and the ability to sleep and resume work.
- Access to the node's precise
[local time](https://substrate.dev/rustdocs/v2.0.0/sp_runtime/offchain/struct.Timestamp.html).
- The ability to sleep and resume work.

OCWs can be initiated from within a special function in your runtime implementation,
`fn offchain_worker(block: T::BlockNumber)`. The function is executed after each block import. To
[`fn offchain_worker(block: T::BlockNumber)`](https://substrate.dev/rustdocs/v2.0.0/frame_support/traits/trait.OffchainWorker.html).
communicate results back to the chain, off-chain workers can submit signed or unsigned transactions
to be included in subsequent blocks.

Expand All @@ -64,7 +69,7 @@ please refer to our [Development Guide](../runtime/off-chain-workers).
As its name indicated, the storage is not stored on-chain. It can be accessed by off-chain worker
threads (both read and write access) and on-chain logic (write only, refer to off-chain indexing
below). This storage is not populated among the blockchain network and does not need to have
consensus computation over.
consensus computation over it.

As an off-chain worker thread is being spawned off during each block import, there could be more
than one off-chain worker thread running at any given time. So, similar to any multi-threaded
Expand All @@ -91,3 +96,6 @@ off-chain storage independently from OCWs. Nodes have to opt-in for persistency
Unlike OCWs, which are not executed during initial blockchain synchronization, off-chain indexing is
populating the storage every time a block is processed, so the data is always consistent and will
be exactly the same for every node with indexing enabled.
## Learn More

- [Off-Chain Workers Development Guide](../runtime/off-chain-workers)
1 change: 1 addition & 0 deletions docs/knowledgebase/runtime/off-chain-workers.md
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,7 @@ using an external library to parse the JSON result in a `no_std` environment.

### Learn More

- [Off-Chain Features Conceptual Guide](../learn-substrate/off-chain-features#off-chain-workers)
- [Signed Transactions](../learn-substrate/extrinsics#signed-transactions)
- [Unsigned Transactions](../learn-substrate/extrinsics#unsigned-transactions)

Expand Down

1 comment on commit f0db1ab

@jimmychu0807
Copy link
Contributor

@jimmychu0807 jimmychu0807 commented on f0db1ab Dec 14, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, thanks Dan.

Please sign in to comment.