In this section we’ll cover the essentials on what you'll need to start building your
offchain::ipfs. We do so by way of:
- Walking you through the example Substrate pallet that's included with
- Providing example code from two Rust clients (
We expect feedback on this pallet, but also we hope that the reference implementation will inspire builders to create their own pallets, expose their own JSON-RPC endpoints, and call them from their applications similarly.
It helps, first, to have a basic understanding of how a request flows from a user of your application, through the Substrate offchain-worker, to the native runtime, over to IPFS, and then all the way back up to your application again.
- Once the chain is initialized or blocks are synced, the embedded Rust IPFS node is launched and connected to the offchain worker runtime. It will stay running in the background.
- The user makes a JSON-RPC call to submit an extrinsic to the node's runtime, using the callable functions exposed from the custom pallet.
- The request is added to the relevant queue in the Substrate storage database. This is also defined in the custom pallet.
- Upon import of specified blocks, the node's runtime passes the requests from the queues to an offchain worker.
- The offchain worker relays the desired requests to the Rust IPFS node, and the node returns futures resolving to results
- The offchain worker registers the results and relays them to the substrate runtime, which processes them and acts upon them as specified in the custom pallet.
- The offchain worker stops running