Task Functions
task()
The task
function contains the core logic of a Koii task, so when developing a new task, the logic for the main work to be performed by nodes will be written here. The proof of work done, which is usually a CID or hash, will be stored on levelDB.
The core logic for the sample task on the template is straightforward: a random number is generated, then it is converted to a string, and then a hash (or CID). The hash is a node's result, sent to K2 for auditing.
fetchSubmission()
The fetchSubmission
function retrieves a node's submission value(CID) from levelDB.
submitTask()
The submitTask
function calls the fetchSubmission
function to retrieve the CID and submits it to K2. To submit results on-chain, it calls the checkSubmissionAndUpdateRound
helper function from namespace
and adds the CID and current round number as parameters.
After the off-chain work is completed and the results are submitted on-chain. The following window is for reviewing the submitted results.
In the following section, we will learn about audit functions.
Last updated