It's stated that fn offchain_worker
function is called every time by all nodes after a block import. Imagine the case where in fn offchain_worker
we make a http call to fetch some not deterministic value from a remote server, and once we get the result we call to pub fn onchain_callback
to sign a transaction to include that result in the blockchain state.
If Off-chain workers are executed by all validators after each block import, would I end up with one new signed transaction per validator with different results (remember is not deterministic).
Example. My Off-chain worker fetch a random number from a remote server and callback the result signing a new transaction. If I have in my network 10 validators... questions:
1.- I would end up with 10 new transactions with different random numbers?
2.- It would be executed only by the validators or also by all the full nodes connected to the blockchain?
3.- Is it possible to trigger the Off-chain workers only when a certain extrinsic is included in the block, instead of after every block import?