diff --git a/lib/blockUnlocker.js b/lib/blockUnlocker.js index fa2fe3332..46c8993ca 100644 --- a/lib/blockUnlocker.js +++ b/lib/blockUnlocker.js @@ -97,20 +97,21 @@ function runInterval(){ function(blocks, callback){ - var redisCommands = blocks.map(function(block){ - return ['hgetall', config.coin + ':shares:round' + block.height]; + var redisCommands = []; + blocks.forEach(function(block) { + redisCommands.push(['hgetall', config.coin + ':shares:round' + block.height]); + redisCommands.push(['del', config.coin + ':shares:round' + block.height]); }); - redisClient.multi(redisCommands).exec(function(error, replies){ if (error){ log('error', logSystem, 'Error with getting round shares from redis %j', [error]); callback(true); return; } - for (var i = 0; i < replies.length; i++){ + for (var i = 0; i < replies.length; i = i + 2){ var workerShares = replies[i]; - blocks[i].workerShares = workerShares; + blocks[i / 2 >> 0].workerShares = workerShares; } callback(null, blocks); }); @@ -123,8 +124,6 @@ function runInterval(){ blocks.forEach(function(block){ if (!block.orphaned) return; - orphanCommands.push(['del', config.coin + ':shares:round' + block.height]); - orphanCommands.push(['zrem', config.coin + ':blocks:candidates', block.serialized]); orphanCommands.push(['zadd', config.coin + ':blocks:matured', block.height, [ block.hash, @@ -166,7 +165,6 @@ function runInterval(){ if (block.orphaned) return; totalBlocksUnlocked++; - unlockedBlocksCommands.push(['del', config.coin + ':shares:round' + block.height]); unlockedBlocksCommands.push(['zrem', config.coin + ':blocks:candidates', block.serialized]); unlockedBlocksCommands.push(['zadd', config.coin + ':blocks:matured', block.height, [ block.hash,