Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Commit

Permalink
Use [email protected] to support excludeOnly option
Browse files Browse the repository at this point in the history
Fixes #7940
  • Loading branch information
mrose17 authored and bsclifton committed Mar 30, 2017
1 parent 34db49e commit 574230f
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 6 deletions.
47 changes: 42 additions & 5 deletions app/ledger.js
Original file line number Diff line number Diff line change
Expand Up @@ -1232,6 +1232,8 @@ var excludeP = (publisher, callback) => {
if (callback) callback(err, result)
}

if (!v2RulesetDB) return setTimeout(() => { excludeP(publisher, callback) }, 5 * msecs.second)

inspectP(v2RulesetDB, v2RulesetPath, publisher, 'exclude', 'domain:' + publisher, (err, result) => {
var props

Expand Down Expand Up @@ -1495,16 +1497,26 @@ var callback = (err, result, delayTime) => {

entries = []
results.forEach((entry) => {
entries.push({ type: 'put',
key: entry.facet + ':' + entry.publisher,
value: JSON.stringify(underscore.omit(entry, [ 'facet', 'publisher' ]))
})
var key = entry.facet + ':' + entry.publisher

if (entry.exclude !== false) {
entries.push({ type: 'put', key: key, value: JSON.stringify(underscore.omit(entry, [ 'facet', 'publisher' ])) })
} else {
entries.push({ type: 'del', key: key })
}
})

v2RulesetDB.batch(entries, (err) => {
if (err) return console.log(v2RulesetPath + ' error: ' + JSON.stringify(err, null, 2))

underscore.keys(synopsis.publishers).forEach((publisher) => { excludeP(publisher) })
if (entries.length === 0) return

underscore.keys(synopsis.publishers).forEach((publisher) => {
// be safe...
if (synopsis.publishers[publisher]) delete synopsis.publishers[publisher].options.exclude

excludeP(publisher)
})
})
}
if (result.publishersV2) {
Expand Down Expand Up @@ -1701,6 +1713,31 @@ var run = (delayTime) => {
* ledger client utilities
*/

/* code that may never be needed...
var rulesV2Reset = (callback) => {
if (clientOptions.verboseP) console.log('\n\nreset rulesets')
if (!v2RulesetDB) return
if (client) {
delete client.state.rulesV2Stamp
client.state.updatesStamp = underscore.now()
}
v2RulesetDB.close((err) => {
if (err) console.log(v2RulesetPath + ' close error: ' + err.toString())
v2RulesetDB = null
require('leveldown').destroy(pathName(v2RulesetPath), (err) => {
if (err) console.log(v2RulesetPath + ' destroy error: ' + err.toString())
v2RulesetDB = levelup(pathName(v2RulesetPath))
callback()
})
})
}
*/

var getStateInfo = (state) => {
var ballots, i, transaction
var info = state.paymentInfo
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
"keytar": "^3.0.0",
"l20n": "^3.5.1",
"ledger-balance": "^0.8.64",
"ledger-client": "^0.9.7",
"ledger-client": "^0.9.8",
"ledger-geoip": "^0.8.75",
"ledger-publisher": "^0.9.0",
"lru-cache": "^1.0.0",
Expand Down

0 comments on commit 574230f

Please sign in to comment.