mirror of
https://github.com/jwinterm/nodejs-pool.git
synced 2026-10-20 05:48:35 +02:00
New cache function for bulk-inserts in single txn to avoid excessive disk writes and blocking by worker.
Adding new getBlockByID function for future tool functionality.
This commit is contained in:
+7
-5
@@ -137,6 +137,7 @@ function updateShareStats() {
|
||||
if (globalMinerList === false) {
|
||||
globalMinerList = [];
|
||||
}
|
||||
let cache_updates = {};
|
||||
// pplns: 0, pps: 0, solo: 0, prop: 0, global: 0
|
||||
['pplns', 'pps', 'solo', 'prop', 'global'].forEach(function (key) {
|
||||
let cachedData = global.database.getCache(key + "_stats");
|
||||
@@ -172,7 +173,7 @@ function updateShareStats() {
|
||||
minerHistory: [{ts: currentTime, cn: cachedData.hash}]
|
||||
};
|
||||
}
|
||||
global.database.setCache(key + "_stats", cachedData);
|
||||
cache_updates[key + "_stats"] = cachedData;
|
||||
});
|
||||
minerList.forEach(function (miner) {
|
||||
if (globalMinerList.indexOf(miner) === -1) {
|
||||
@@ -206,7 +207,7 @@ function updateShareStats() {
|
||||
badShares: 0
|
||||
};
|
||||
}
|
||||
global.database.setCache(miner, cachedData);
|
||||
cache_updates[miner] = cachedData;
|
||||
});
|
||||
globalMinerList.forEach(function (miner) {
|
||||
if (minerList.indexOf(miner) === -1) {
|
||||
@@ -234,14 +235,15 @@ function updateShareStats() {
|
||||
});
|
||||
}
|
||||
minerStats.hash = 0;
|
||||
global.database.setCache(miner, minerStats);
|
||||
cache_updates[miner] = minerStats;
|
||||
}
|
||||
}
|
||||
});
|
||||
Object.keys(identifiers).forEach(function (key) {
|
||||
global.database.setCache(key + '_identifiers', identifiers[key]);
|
||||
cache_updates[key + '_identifiers'] = identifiers[key];
|
||||
});
|
||||
global.database.setCache('minerList', globalMinerList);
|
||||
cache_updates['minerList'] = globalMinerList;
|
||||
global.database.bulkSetCache(cache_updates);
|
||||
callback(null);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user