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

Change ballot commit interval to [1s..5m] #47

Merged
merged 2 commits into from
Apr 4, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -994,7 +994,8 @@ Client.prototype._currentReconcile = function (callback) {

transaction = { viewingId: viewingId,
surveyorId: surveyorInfo.surveyorId,
contribution: { fiat: { amount: amount, currency: currency },
contribution: {
fiat: { amount: amount, currency: currency },
rates: rates,
satoshis: body.satoshis,
altcurrency: body.altcurrency,
Expand Down Expand Up @@ -1129,12 +1130,13 @@ Client.prototype._prepareBallot = function (ballot, transaction, callback) {
ballot.prepareBallot = underscore.defaults(body, { server: self.options.server })

now = underscore.now()
delayTime = random.randomInt({ min: msecs.second, max: self.options.debugP ? msecs.minute : 3 * msecs.hour })
delayTime = random.randomInt({ min: 10 * msecs.second, max: (this.options.debugP ? 1 : 5) * msecs.minute })
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was this intentionally changed from self to this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch! fixed.

ballot.delayStamp = now + delayTime
if (self.options.verboseP) ballot.delayDate = new Date(ballot.delayStamp)

self._log('_prepareBallot', { delayTime: msecs.minute })
callback(null, self.state, msecs.minute)
if (delayTime > msecs.minute) delayTime = msecs.minute
self._log('_prepareBallot', { delayTime: delayTime })
callback(null, self.state, delayTime)
})
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bat-client",
"version": "2.1.2",
"version": "2.1.3",
"description": "An example of client code for the BAT.",
"main": "index.js",
"scripts": {
Expand Down