pragma solidity ^0.4.18; contract Decentralized_Computations { uint numJobs; struct Job{ string name; // job name string description; // job description address publisher; //address of person who submitted the job uint amount; // amount he is willing to pay string map_code_hash; // mapper code string reduce_code_hash; // reduce code string result_hash; // job result hash uint num_tasks; mapping (uint => Task) all_tasks; // list of all tasks {key:task_data,value:task} } mapping (uint => Job) alljobs; //list of all jobs struct Task{ string data_hash; // task data hash bool status; // status string output_hash; // output of task address website_address; // website which completed the task } struct website{ string url; //url of website address website_address; //address for transferring funds } mapping (uint => website[]) subscribed_websites; // all the websites who subscribed to job {job:[websites]} function createJob(string name,string desc,address pub,uint amt,string map_hash,string reduce_hash) public returns (uint numJobs){ numJobs = numJobs++; // numJobs is return variable Job job = alljobs[numJobs]; job.name = name; job.description = desc; job.publisher = pub; job.amount = amt; job.map_code_hash = map_hash; job.reduce_code_hash = reduce_hash; } function addTasks(uint jobid,string hash) public returns (bool success){ Job job = alljobs[jobid]; Task task = job.all_tasks[job.num_tasks++]; task.data_hash = hash; task.status = false; return true; } function subscribeJob(uint jobid,string url,address web_address) public returns (bool success){ website[] websites = subscribed_websites[jobid]; website memory site; site.url = url; site.website_address = web_address; websites.push(site); return true; } }
0.4.18