Adapt solo pool for current Peya and shared util

This commit is contained in:
Codex Bot
2026-03-21 15:08:23 +01:00
parent 8f7418757c
commit 999186ab6d
7 changed files with 305 additions and 363 deletions

View File

@@ -11,10 +11,25 @@
// Load required modules
let fs = require('fs');
let emailSystem = require('./email.js');
let telegram = require('./telegram.js');
let utils = require('./utils.js');
let emailSystem = null;
let telegram = null;
function getEmailSystem () {
if (!emailSystem) {
emailSystem = require('./email.js');
}
return emailSystem;
}
function getTelegram () {
if (!telegram) {
telegram = require('./telegram.js');
}
return telegram;
}
// Initialize log system
let logSystem = 'notifications';
require('./exceptionWriter.js')(logSystem);
@@ -111,7 +126,7 @@ function sendToTelegramChannel (id, variables) {
}
let chatId = '@' + channel;
telegram.sendMessage(chatId, message);
getTelegram().sendMessage(chatId, message);
}
}
exports.sendToTelegramChannel = sendToTelegramChannel;
@@ -133,7 +148,7 @@ function sendToMinerTelegram (miner, id, variables) {
redisClient.hget(config.coin + ':telegram', miner, function (error, chatId) {
if (error || !chatId) return;
telegram.sendMessage(chatId, message);
getTelegram().sendMessage(chatId, message);
});
}
}
@@ -158,7 +173,7 @@ function sendBlockTelegram (id, variables) {
if (error || !data) return;
for (let chatId in data) {
if (!chatId) continue;
telegram.sendMessage(chatId, message);
getTelegram().sendMessage(chatId, message);
}
});
}
@@ -185,7 +200,7 @@ function sendToAllEmails (id, variables) {
if (error || !data) return;
for (let address in data) {
let email = data[address];
emailSystem.sendEmail(email, subject, content);
getEmailSystem().sendEmail(email, subject, content);
}
});
}
@@ -210,7 +225,7 @@ function sendToMinerEmail (miner, id, variables) {
redisClient.hget(config.coin + ':notifications', miner, function (error, email) {
if (error || !email) return;
emailSystem.sendEmail(email, subject, content);
getEmailSystem().sendEmail(email, subject, content);
});
}
}
@@ -232,7 +247,7 @@ function sendToEmail (email, id, variables) {
return;
}
emailSystem.sendEmail(email, subject, content);
getEmailSystem().sendEmail(email, subject, content);
}
}
exports.sendToEmail = sendToEmail;