diff --git a/lib/historyKeeper.js b/lib/historyKeeper.js index 85bc73ab1..ff0327751 100644 --- a/lib/historyKeeper.js +++ b/lib/historyKeeper.js @@ -31,7 +31,6 @@ module.exports.create = function (config, cb) { // and more easily share state between historyKeeper and rpc const Env = { Log: Log, - // tasks // store id: Crypto.randomBytes(8).toString('hex'), @@ -261,11 +260,6 @@ module.exports.create = function (config, cb) { } })); }).nThen(function (w) { - // create a task store (for scheduling tasks) - require("./storage/tasks").create(config, w(function (e, tasks) { - if (e) { throw e; } - Env.tasks = tasks; - })); if (config.disableIntegratedTasks) { return; } config.intervals = config.intervals || {}; diff --git a/lib/hk-util.js b/lib/hk-util.js index e9943f1c1..0e79c0691 100644 --- a/lib/hk-util.js +++ b/lib/hk-util.js @@ -529,7 +529,7 @@ const handleFirstMessage = function (Env, channelName, metadata) { if(metadata.expire && typeof(metadata.expire) === 'number') { // the fun part... // the user has said they want this pad to expire at some point - Env.tasks.write(metadata.expire, "EXPIRE", [ channelName ], function (err) { + Env.writeTask(metadata.expire, "EXPIRE", [ channelName ], function (err) { if (err) { // if there is an error, we don't want to crash the whole server... // just log it, and if there's a problem you'll be able to fix it diff --git a/lib/workers/db-worker.js b/lib/workers/db-worker.js index d76ce61dd..0f3d3b87f 100644 --- a/lib/workers/db-worker.js +++ b/lib/workers/db-worker.js @@ -419,6 +419,10 @@ const runTasks = function (data, cb) { Env.tasks.runAll(cb); }; +const writeTask = function (data, cb) { + Env.tasks.write(data.time, data.task_command, data.args, cb); +}; + const COMMANDS = { COMPUTE_INDEX: computeIndex, COMPUTE_METADATA: computeMetadata, @@ -431,6 +435,7 @@ const COMMANDS = { GET_HASH_OFFSET: getHashOffset, REMOVE_OWNED_BLOB: removeOwnedBlob, RUN_TASKS: runTasks, + WRITE_TASK: writeTask, }; COMMANDS.INLINE = function (data, cb) { diff --git a/lib/workers/index.js b/lib/workers/index.js index 2ad7377a4..cc11d538b 100644 --- a/lib/workers/index.js +++ b/lib/workers/index.js @@ -323,6 +323,15 @@ Workers.initialize = function (Env, config, _cb) { }, cb); }; + Env.writeTask = function (time, command, args, cb) { + sendCommand({ + command: 'WRITE_TASK', + time: time, + task_command: command, + args: args, + }, cb); + }; + // Synchronous crypto functions Env.validateMessage = function (signedMsg, key, cb) { sendCommand({