Add Salvium fork mechanics: config schema and utility functions
Co-authored-by: t1amak <57602242+t1amak@users.noreply.github.com>
This commit is contained in:
@@ -28,6 +28,33 @@ if (!config.poolServer.paymentId.addressSeparator) config.poolServer.paymentId.a
|
||||
if (!config.payments.priority) config.payments.priority = 0;
|
||||
|
||||
function runInterval () {
|
||||
// Check for Salvium payout blackout
|
||||
if (utils.isSalviumEnabled()) {
|
||||
apiInterfaces.rpcDaemon('getblockcount', [], function (error, result) {
|
||||
if (error) {
|
||||
log('error', logSystem, 'Error getting block count for Salvium check: %j', [error]);
|
||||
return;
|
||||
}
|
||||
|
||||
let currentHeight = result.count - 1; // getblockcount returns height + 1
|
||||
let salviumState = utils.getSalviumState(currentHeight);
|
||||
|
||||
if (salviumState === 'payout_blackout') {
|
||||
log('info', logSystem, 'Salvium payout blackout active at height %d. Skipping payment processing.', [currentHeight]);
|
||||
return;
|
||||
}
|
||||
|
||||
// Continue with normal payment processing
|
||||
processSalviumAwarePayments(currentHeight);
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
// Non-Salvium payment processing
|
||||
processSalviumAwarePayments(0);
|
||||
}
|
||||
|
||||
function processSalviumAwarePayments(currentHeight) {
|
||||
async.waterfall([
|
||||
|
||||
// Get worker keys
|
||||
@@ -141,15 +168,51 @@ function runInterval () {
|
||||
|
||||
let address = worker;
|
||||
let payment_id = null;
|
||||
|
||||
let with_payment_id = false;
|
||||
|
||||
let addr = address.split(config.poolServer.paymentId.addressSeparator);
|
||||
if ((addr.length === 1 && utils.isIntegratedAddress(address)) || addr.length >= 2) {
|
||||
with_payment_id = true;
|
||||
if (addr.length >= 2) {
|
||||
// Handle Salvium dual address and carrot switching
|
||||
if (utils.isSalviumEnabled()) {
|
||||
let salviumState = utils.getSalviumState(currentHeight);
|
||||
|
||||
if (salviumState === 'carrot_payouts') {
|
||||
// Switch to carrot address for payouts
|
||||
let dualAddress = utils.parseSalviumDualAddress(worker);
|
||||
if (dualAddress) {
|
||||
address = dualAddress.carrot;
|
||||
log('info', logSystem, 'Salvium: Sending payment to carrot address %s', [address]);
|
||||
} else {
|
||||
// For backwards compatibility, if no dual address, try to parse as single address
|
||||
let addr = address.split(config.poolServer.paymentId.addressSeparator);
|
||||
address = addr[0];
|
||||
payment_id = addr[1] || null;
|
||||
}
|
||||
} else if (salviumState === 'dual_required') {
|
||||
// Still pay to cryptonote address but parse dual format
|
||||
let dualAddress = utils.parseSalviumDualAddress(worker);
|
||||
if (dualAddress) {
|
||||
address = dualAddress.cryptonote;
|
||||
} else {
|
||||
let addr = address.split(config.poolServer.paymentId.addressSeparator);
|
||||
address = addr[0];
|
||||
payment_id = addr[1] || null;
|
||||
}
|
||||
} else {
|
||||
// Normal payment processing for other heights
|
||||
let addr = address.split(config.poolServer.paymentId.addressSeparator);
|
||||
address = addr[0];
|
||||
payment_id = addr[1];
|
||||
payment_id = addr[1] || null;
|
||||
}
|
||||
} else {
|
||||
// Standard address parsing for non-Salvium coins
|
||||
let addr = address.split(config.poolServer.paymentId.addressSeparator);
|
||||
address = addr[0];
|
||||
payment_id = addr[1] || null;
|
||||
}
|
||||
|
||||
// Payment ID validation (existing logic)
|
||||
if ((utils.isIntegratedAddress && utils.isIntegratedAddress(address)) || payment_id) {
|
||||
with_payment_id = true;
|
||||
if (payment_id) {
|
||||
payment_id = payment_id.replace(/[^A-Za-z0-9]/g, '');
|
||||
if (payment_id.length !== 16 && payment_id.length !== 64) {
|
||||
with_payment_id = false;
|
||||
@@ -164,7 +227,7 @@ function runInterval () {
|
||||
}
|
||||
|
||||
if (config.poolServer.fixedDiff && config.poolServer.fixedDiff.enabled) {
|
||||
addr = address.split(config.poolServer.fixedDiff.addressSeparator);
|
||||
let addr = address.split(config.poolServer.fixedDiff.addressSeparator);
|
||||
if (addr.length >= 2) address = addr[0];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user