From 77c499c95a9db354aa85174e7fc8a873936b0aed Mon Sep 17 00:00:00 2001 From: NejcZdovc Date: Tue, 4 Apr 2017 20:54:49 +0200 Subject: [PATCH] Fixes usage of ledger advance settings in the ledger table Resolves #7987 Auditors: @mrose17 @diracdeltas Test Plan: - enable payments - visit site for at least 8 seconds or until it appears in the synopsis table - set minimum visits to 5 instead of 1 - site shouldn't be in the ledger table --- app/ledger.js | 27 ++++++++++++------- .../preferences/payment/advancedSettings.js | 5 ++-- docs/state.md | 2 +- js/constants/appConfig.js | 2 +- 4 files changed, 22 insertions(+), 14 deletions(-) diff --git a/app/ledger.js b/app/ledger.js index 6cb5bac3a73..83fbe8e37f1 100644 --- a/app/ledger.js +++ b/app/ledger.js @@ -176,7 +176,7 @@ const doAction = (action) => { case settings.MINIMUM_VISIT_TIME: if (action.value <= 0) break - synopsis.options.minDuration = action.value + synopsis.options.minPublisherDuration = action.value updatePublisherInfo() break @@ -741,8 +741,9 @@ var enable = (paymentsEnabled) => { value = 8 * 1000 appActions.changeSetting(settings.MINIMUM_VISIT_TIME, value) } + // for earlier versions of the code... - if ((value > 0) && (value < 1000)) synopsis.options.minDuration = value * 1000 + if ((value > 0) && (value < 1000)) synopsis.options.minPublisherDuration = value * 1000 value = getSetting(settings.MINIMUM_VISITS) if (!value) { @@ -752,13 +753,10 @@ var enable = (paymentsEnabled) => { if (value > 0) synopsis.options.minPublisherVisits = value if (process.env.NODE_ENV === 'test') { - synopsis.options.minDuration = 0 + synopsis.options.minDuration = 0 // TODO remove when we update publisher synopsis.options.minPublisherDuration = 0 synopsis.options.minPublisherVisits = 0 } else { - if (process.env.LEDGER_PUBLISHER_VISIT_DURATION) { - synopsis.options.minDuration = ledgerClient.prototype.numbion(process.env.LEDGER_PUBLISHER_VISIT_DURATION) - } if (process.env.LEDGER_PUBLISHER_MIN_DURATION) { synopsis.options.minPublisherDuration = ledgerClient.prototype.numbion(process.env.LEDGER_PUBLISHER_MIN_DURATION) } @@ -1028,15 +1026,24 @@ var stickyP = (publisher) => { } var eligibleP = (publisher) => { + if (!synopsis.options.minPublisherDuration && process.env.NODE_ENV !== 'test') { + synopsis.options.minPublisherDuration = getSetting(settings.MINIMUM_VISIT_TIME) + } + return ((synopsis.publishers[publisher].scores[synopsis.options.scorekeeper] > 0) && (synopsis.publishers[publisher].duration >= synopsis.options.minPublisherDuration) && (synopsis.publishers[publisher].visits >= synopsis.options.minPublisherVisits)) } var visibleP = (publisher) => { - return (((stickyP(publisher)) || - ((synopsis.publishers[publisher].options.exclude !== true) && (eligibleP(publisher)))) && - (!blockedP(publisher))) + return ( + eligibleP(publisher) && + ( + synopsis.publishers[publisher].options.exclude !== true || + stickyP(publisher) + ) + ) && + !blockedP(publisher) } var contributeP = (publisher) => { @@ -1466,7 +1473,7 @@ var ledgerInfo = { passphrase: undefined, // advanced ledger settings - minDuration: undefined, + minPublisherDuration: undefined, minPublisherVisits: undefined, hasBitcoinHandler: false, diff --git a/app/renderer/components/preferences/payment/advancedSettings.js b/app/renderer/components/preferences/payment/advancedSettings.js index d961d192e03..f113c24bc4d 100644 --- a/app/renderer/components/preferences/payment/advancedSettings.js +++ b/app/renderer/components/preferences/payment/advancedSettings.js @@ -7,6 +7,7 @@ const {StyleSheet, css} = require('aphrodite') // util const {changeSetting} = require('../../../lib/settingsUtil') +const appConfig = require('../../../../../js/constants/appConfig') // components const Button = require('../../../../../js/components/button') @@ -24,7 +25,7 @@ const settings = require('../../../../../js/constants/settings') class AdvancedSettingsContent extends ImmutableComponent { render () { - const minDuration = this.props.ledgerData.getIn(['synopsisOptions', 'minDuration']) + const minPublisherDuration = this.props.ledgerData.getIn(['synopsisOptions', 'minPublisherDuration']) const minPublisherVisits = this.props.ledgerData.getIn(['synopsisOptions', 'minPublisherVisits']) return
@@ -35,7 +36,7 @@ class AdvancedSettingsContent extends ImmutableComponent {