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

Commit

Permalink
Updates bat libraries
Browse files Browse the repository at this point in the history
Resolves #13509

Auditors:

Test Plan:
  • Loading branch information
NejcZdovc committed Mar 23, 2018
1 parent 777291b commit 1fccb85
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 15 deletions.
32 changes: 30 additions & 2 deletions app/browser/api/ledger.js
Original file line number Diff line number Diff line change
Expand Up @@ -2344,12 +2344,37 @@ const run = (state, delayTime) => {
const ballots = client.ballots()
const data = (synopsis) && (ballots > 0) && synopsisNormalizer(state, null, false, true)

let map = null

if (data) {
let weights = []
map = {}

data.forEach((datum) => {
weights.push({publisher: datum.publisherKey, weight: datum.weight / 100.0})
map[datum.publisherKey] = {
verified: datum.verified,
exclude: datum.exclude,
score: datum.score,
pinPercentage: datum.pinPercentage,
percentage: datum.percentage,
votes: 0,
weight: datum.weight
}

weights.push({
publisher: datum.publisherKey,
pinPercentage: datum.pinPercentage,
weight: datum.weight / 100.0
})
})
winners = synopsis.winners(ballots, weights)

winners = synopsis.winners(ballots, weights) || []

winners.forEach((winner) => {
if (map[winner]) map[winner].votes++
})

client.memo('run:ballots', Object.values(map))
}

if (!winners) winners = []
Expand All @@ -2362,6 +2387,9 @@ const run = (state, delayTime) => {
const result = client.vote(winner)
if (result) stateData = result
})
if (!stateData && map) {
stateData = client.state
}
if (stateData) muonWriter(statePath, stateData)
} catch (ex) {
console.error('ledger client error(2): ' + ex.toString() + (ex.stack ? ('\n' + ex.stack) : ''))
Expand Down
22 changes: 11 additions & 11 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@
"aphrodite": "1.1.0",
"async": "^2.0.1",
"bat-balance": "^1.0.7",
"bat-client": "^2.1.1",
"bat-publisher": "^2.0.13",
"bat-client": "^2.1.2",
"bat-publisher": "^2.0.15",
"bignumber.js": "^4.0.4",
"bloodhound-js": "brave/bloodhound",
"clipboard-copy": "^1.0.0",
Expand Down
1 change: 1 addition & 0 deletions test/unit/app/browser/api/ledgerTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ describe('ledger api unit tests', function () {
getPaymentId: function () {
return 'payementIdGoesHere'
},
memo: () => {},
properties: {
wallet: {
paymentId: 12345
Expand Down

0 comments on commit 1fccb85

Please sign in to comment.