@@ -39,16 +39,21 @@ easily access on-chain state for their computations.
39
39
40
40
Off-chain workers have access to extended APIs for communicating with the external world:
41
41
42
- - Ability to submit transactions (either signed or unsigned) to the chain to publish computation
43
- results.
42
+ - Ability to
43
+ [ submit transactions] ( https://substrate.dev/rustdocs/v2.0.0/sp_runtime/offchain/trait.TransactionPool.html )
44
+ (either signed or unsigned) to the chain to publish computation results.
44
45
- A fully-featured HTTP client allowing the worker to access and fetch data from external services.
45
46
- Access to the local keystore to sign and verify statements or transactions.
46
- - An additional, local key-value database shared between all off-chain workers.
47
+ - An additional, local
48
+ [ key-value database] ( https://substrate.dev/rustdocs/v2.0.0/sp_runtime/offchain/trait.OffchainStorage.html )
49
+ shared between all off-chain workers.
47
50
- A secure, local entropy source for random number generation.
48
- - Access to the node's precise local time and the ability to sleep and resume work.
51
+ - Access to the node's precise
52
+ [ local time] ( https://substrate.dev/rustdocs/v2.0.0/sp_runtime/offchain/struct.Timestamp.html ) .
53
+ - The ability to sleep and resume work.
49
54
50
55
OCWs can be initiated from within a special function in your runtime implementation,
51
- ` fn offchain_worker(block: T::BlockNumber) ` . The function is executed after each block import. To
56
+ [ ` fn offchain_worker(block: T::BlockNumber) ` ] ( https://substrate.dev/rustdocs/v2.0.0/frame_support/traits/trait.OffchainWorker.html ) .
52
57
communicate results back to the chain, off-chain workers can submit signed or unsigned transactions
53
58
to be included in subsequent blocks.
54
59
@@ -64,7 +69,7 @@ please refer to our [Development Guide](../runtime/off-chain-workers).
64
69
As its name indicated, the storage is not stored on-chain. It can be accessed by off-chain worker
65
70
threads (both read and write access) and on-chain logic (write only, refer to off-chain indexing
66
71
below). This storage is not populated among the blockchain network and does not need to have
67
- consensus computation over.
72
+ consensus computation over it.
68
73
69
74
As an off-chain worker thread is being spawned off during each block import, there could be more
70
75
than one off-chain worker thread running at any given time. So, similar to any multi-threaded
@@ -91,3 +96,6 @@ off-chain storage independently from OCWs. Nodes have to opt-in for persistency
91
96
Unlike OCWs, which are not executed during initial blockchain synchronization, off-chain indexing is
92
97
populating the storage every time a block is processed, so the data is always consistent and will
93
98
be exactly the same for every node with indexing enabled.
99
+ ## Learn More
100
+
101
+ - [ Off-Chain Workers Development Guide] ( ../runtime/off-chain-workers )
0 commit comments