Skip to content

Commit

Permalink
changed underlying market cache function
Browse files Browse the repository at this point in the history
  • Loading branch information
nothingisdead committed Jun 29, 2014
1 parent c63ecfe commit f3931bf
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 16 deletions.
34 changes: 19 additions & 15 deletions cryptsy.js
Expand Up @@ -98,14 +98,31 @@ function CryptsyClient(key, secret, requeue) {
});
}

function getmarketids(callback) {
var callback2 = function(error, markets) {
self.markets = {};

for(var i in markets) {
var primary = markets[i].primary_currency_code;
var secondary = markets[i].secondary_currency_code;

self.markets[primary + secondary] = markets[i].marketid;
}

callback(error, self.markets);
};

self.getmarkets(callback2);
}

// This function gets the market id for a market in the format 'LTCBTC'
self.getmarketid = function(marketname, callback) {
if(typeof callback !== 'function') {
throw new Error("'callback' argument must be a function.");
}

if(!self.markets || !Object.keys(self.markets).length) {
self.getmarkets(function(error, markets) {
getmarketids(function(error, markets) {
callback.call(this, error, markets[marketname]);
});
}
Expand Down Expand Up @@ -145,20 +162,7 @@ function CryptsyClient(key, secret, requeue) {
};

self.getmarkets = function(callback) {
callback2 = function(error, markets) {
self.markets = {};

for(var i in markets) {
var primary = markets[i].primary_currency_code;
var secondary = markets[i].secondary_currency_code;

self.markets[primary + secondary] = markets[i].marketid;
}

callback(error, self.markets);
};

api_query('getmarkets', callback2);
api_query('getmarkets', callback);
};

self.mytransactions = function(callback) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "cryptsy-api",
"version": "0.2.4",
"version": "0.2.5",
"description": "cryptsy.com API client for node.js",
"keywords": [
"btc",
Expand Down

0 comments on commit f3931bf

Please sign in to comment.