I am requesting Bitstamp API in parrallel:
// Simplified version
var async = require(\'async\');
var bitstamp = require(\'bitstamp\');
async.parallel([
bit
(author of the npm module here)
I solved it by adding my own counter at the end of the ms timestamp. It now supports up to 999 calls per ms because of this function. The first time it will generate something like 1409074885767000
and if you need a new nonce during the same ms it will then generate 1409074885767001
, 1409074885767002
, ...
npm nonce module is now generate it correctly
I had exactly the same problem, so I took askmike's code and modified it slightly.
var nonce = new (function() {
this.generate = function() {
var now = Date.now();
this.counter = (now === this.last? this.counter + 1 : 0);
this.last = now;
// add padding to nonce
var padding =
this.counter < 10 ? '000' :
this.counter < 100 ? '00' :
this.counter < 1000 ? '0' : '';
return now+padding+this.counter;
};
})();
use it like this
nonce.generate();
check out my jsfiddle with example