🅱
Attaching RaaS (renew, repair, replication) Worker
Attaching a RaaS worker on-demand to trigger storage deals for files uploaded through the Lighthouse Smart Contract
RaaS (renew, repair, replication) workers interact with Lighthouse Smart Contracts to start deal-making for the data submitted using the
submit
functionUploading via Lighthouse SDK already has a RaaS worker running under the hood tightly coupled with File Upload. This section discusses attaching the RaaS Worker on-demand to your data uploaded via Lighthouse Smart Contract
Functions and paarameters for RaaS worker are as follows
# | Function Name | Parameters | Parameter Info | Default Value |
---|---|---|---|---|
1 | register_job | cid | cid to register | |
| | endDate | time at which deal should ideally end | 1 month |
| | jobType | renew, replication or all | all |
| | replicationTarget | number of replications | 2 |
| | aggregator | lighthouse | lighthouse |
| | epochs | how many epochs before deal expiry should deal be renewed | 4 |
2 | deal_status | cid | cid to check deal status for | |
You can register RaaS workers for any CID (including ones of files you didn't upload) by making a POST request to
https://calibration.lighthouse.storage/api/register_job
with your CID as the body of the request as below - # Example of registering a job
curl -X POST https://calibration.lighthouse.storage/api/register_job \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "cid=QmYSNU2i62v4EFvLehikb4njRiBrcWqH6STpMwduDcNmK6"
or via code
const axios = require('axios')
const register_job = async() =>{
const formData = new FormData();
const cid = "QmTgLAp2Ze2bv7WV2wnZrvtpR5pKJxZ2vtBxZPwr7rM61a"
const requestReceivedTime = new Date()
const endDate = requestReceivedTime.setMonth(requestReceivedTime.getMonth() + 1)
const replicationTarget = 2
const epochs = 4 // how many epochs before deal end should deal be renewed
formData.append('cid', cid)
formData.append('endDate', endDate)
formData.append('replicationTarget', replicationTarget)
formData.append('epochs', epochs)
const response = await axios.post(
`https://calibration.lighthouse.storage/api/register_job`,
formData
)
console.log(response.data)
}
register_job()
You'll then be able to query the deal's status using the
deal_status
endpoint# Example of how to query a job's status using its CID
curl -X GET "https://calibration.lighthouse.storage/api/deal_status?CID=your_CID_here"
Building a decentralized application (dApp) or a Decentralized Autonomous Organization (DAO) to incentivize replications, renewals, and repairs of existing data could create a more resilient and economically sustainable data storage ecosystem. Some unique applications include:
- Rewarding $TOKEN for replicating a useful piece CID (deemed valuable by the TOKEN protocol).
- Example use-case of Attaching RaaS Worker on-demand: Incentivize one set of users to upload data via Smart Contract (using the submit function) and another set to run RaaS workers.