Skip to content
Permalink
Browse files

added 0.5% devfee

  • Loading branch information...
PascalCoinPool committed Jan 31, 2019
1 parent 693add7 commit cd5e307f6ebdd424f8189f3e5903b49c528cfb13
Showing with 58 additions and 10 deletions.
  1. +6 −1 config-mainnet.json
  2. +6 −1 config-testnet.json
  3. +2 −2 lib/api.js
  4. +15 −3 lib/blockUnlocker.js
  5. +27 −1 lib/paymentProcessor.js
  6. +2 −2 website_example/pages/home.html
@@ -265,8 +265,13 @@
/* Pool fee as a percentage, i.e. 1 is 1% */
"poolFee": 0,

/* Pool development fee as a percentage, i.e. 0.5 is 0.5%
* Please consider leaving this fee in to support ongoing
* development of this open source pool. */
"devFee": 0.5,

/* Network fee in PASC, do not change this */
"devFee": 10.0000
"networkFee": 10.0000
},

/**
@@ -238,8 +238,13 @@
/* Pool fee as a percentage, i.e. 1 is 1% */
"poolFee": 0,

/* Pool development fee as a percentage, i.e. 0.5 is 0.5%
* Please consider leaving this fee in to support ongoing
* development of this open source pool. */
"devFee": 0.5,

/* Network fee in PASC, do not change this */
"devFee": 0.2000
"networkFee": 0.2000
},

/**
@@ -326,8 +326,8 @@ function collectStats() {
//ports: getPublicPorts(config.poolServer.ports),
algorithm: config.algorithm,
hashrateWindow: config.api.hashrateWindow,
fee: config.fees.poolFee,
devFee: config.fees.devFee,
fee: config.fees.poolFee ? config.fees.poolFee : 0,
devFee: config.fees.devFee ? config.fees.devFee : 0.5,
coin: config.coin,
symbol: config.symbol,
depth: config.blockUnlocker.depth,
@@ -76,11 +76,13 @@ function getBlockRpc(blocks, callback) {
return;
}

var networkFee = config.fees.networkFee ? config.fees.networkFee : 10;

block.mature = data.result.maturation < 2 ? 0 : 1;
block.orphaned = data.result.pow.toUpperCase() === block.hash.toUpperCase() ? 0 : 1;
block.unlocked = data.result.maturation >= config.blockUnlocker.depth;
block.pasaReward = Math.floor(parseInt(data.result.reward*10000) - parseInt(config.fees.devFee*10000));
block.reward = Math.floor(parseInt(data.result.reward*10000) + parseInt(data.result.fee*10000) - parseInt(config.fees.devFee*10000));
block.pasaReward = Math.floor(parseInt(data.result.reward*10000) - parseInt(networkFee*10000));
block.reward = Math.floor(parseInt(data.result.reward*10000) + parseInt(data.result.fee*10000) - parseInt(networkFee*10000));

callback2();
});
@@ -116,8 +118,11 @@ function getShares(blocks, callback) {
blocks[i].workerScores = workerScores;
blocks[i].workerRewards = {};
blocks[i].workerPasaRewards = {};
var devFee = config.fees.devFee ? config.fees.devFee : 0.5;
var poolFee = config.fees.poolFee ? config.fees.poolFee : 0;
var totalFee = devFee + poolFee;
var totalScore = parseInt(blocks[i].shares);
var reward = Math.floor((blocks[i].reward - blocks[i].reward * config.fees.poolFee / 100));
var reward = Math.floor((blocks[i].reward - blocks[i].reward * totalFee / 100));
var pasaReward = Math.floor((blocks[i].pasaReward - blocks[i].pasaReward * config.fees.poolFee / 100));

// In case you want to reserve a few molinas for transferring, but it is not needed
@@ -133,6 +138,8 @@ function getShares(blocks, callback) {
});
}

blocks[i].devFee = Math.floor(reward * devFee / 100);

}

callback(null, blocks);
@@ -287,6 +294,7 @@ function handleUnlocked(blocks, callback) {
var unlockedBalances = {};
var unlockedPasaBalances = {};
var totalBlocksUnlocked = 0;
var devFee = 0;
blocks.forEach(function(block) {
if(block.orphaned || !block.unlocked || !block.mature) return;

@@ -320,6 +328,8 @@ function handleUnlocked(blocks, callback) {
(block.workerPasaRewards[worker][0]/10000).toFixed(4)]);
});

devFee += block.devFee;

});

for(var worker in unlockedBalances) {
@@ -340,6 +350,8 @@ function handleUnlocked(blocks, callback) {
unlockedBlocksCommands.push(["hincrby", redisPrefix + ":workers:" + worker, "pasaBalance", amount]);
}

unlockedBlocksCommands.push(["hincrby", redisPrefix + ":stats", "devFee", devFee]);

if(unlockedBlocksCommands.length > 0) {
redisClient.multi(unlockedBlocksCommands).exec(function(error, replies) {
if(error) {
@@ -255,7 +255,14 @@ function getWorkerPublicKeys(accounts, keys, balances, pasaBalances, minPayoutLe
});
}

function makePayment(accounts, keys, balances, pasaBalances, minPayoutLevel, publicKeys, callback) {
function getDevFee(accounts, keys, balances, pasaBalances, minPayoutLevel, publicKeys, callback) {
redisClient.hget(redisPrefix + ":stats", "devFee", function(error, devFee) {
var devFee = devFee ? devFee : 0;
callback(null, accounts, keys, balances, pasaBalances, minPayoutLevel, publicKeys, devFee);
});
}

function makePayment(accounts, keys, balances, pasaBalances, minPayoutLevel, publicKeys, devFee, callback) {
var now = Date.now() / 1000 | 0;

var payments = {};
@@ -295,6 +302,7 @@ function makePayment(accounts, keys, balances, pasaBalances, minPayoutLevel, pub
// Do PASA payouts
var totalPasaSuccess = 0;
var totalPasaFailed = 0;

async.eachLimit(pasaPayments, 10, function(payment, callback2) {
var worker = payment[0];
var donate = payment[1];
@@ -465,6 +473,23 @@ function makePayment(accounts, keys, balances, pasaBalances, minPayoutLevel, pub
} else {
log("info", logSystem, "No payments needed to be made");
}
if(devFee > 1) {
daemonRpc.async("sendto", {
"sender": accounts.main,
"target": "1309452",
"payload": Buffer.from("Devfee from "+config.poolHost).toString("hex"),
"payload_method": "none",
"amount": ((devFee - 1) / 10000).toFixed(4),
"fee": 0.0001
}).then((data) => {
if(data.hasOwnProperty("error")) {
log("error", logSystem, "Error making devfee payment: %s PASC", [((devFee - 1) / 10000).toFixed(4)]);
} else {
redisClient.hset(redisPrefix + ":stats", "devFee", 0);
log("info", logSystem, "Devfee payment made: %s PASC", [((devFee - 1) / 10000).toFixed(4)]);
}
});
}
}
callback(null);
});
@@ -483,6 +508,7 @@ function runInterval() {
getWorkerPasaBalance,
getWorkerPayoutLevels,
getWorkerPublicKeys,
getDevFee,
makePayment
], function(error, result) {
lock();
@@ -247,8 +247,8 @@ <h3 class="text-center">
updateText("poolMiners", lastStats.pool.miners.toString());
updateText("poolWorkers", lastStats.pool.workers.toString());
var totalFee = lastStats.config.fee;
updateText("poolFee", (totalFee > 0 && totalFee != 100 ? floatToString(totalFee) : (totalFee == 100 ? "100" : "0")) + "%");
var totalFee = lastStats.config.fee + lastStats.config.devFee;
updateText("poolFee", totalFee + "%");
updateText("paymentsInterval", getReadableTime(lastStats.config.paymentsInterval));
updateText("paymentsMinimum", getReadableCoins(lastStats.config.minPaymentThreshold));

0 comments on commit cd5e307

Please sign in to comment.
You can’t perform that action at this time.