From d2ba8f1c27d244e0595017aa6cbac506e8ea6400 Mon Sep 17 00:00:00 2001 From: yflory Date: Thu, 11 May 2017 18:07:29 +0200 Subject: [PATCH] Use the new format for the storage limits --- rpc.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/rpc.js b/rpc.js index 2e603d7fb..d9a619823 100644 --- a/rpc.js +++ b/rpc.js @@ -458,6 +458,8 @@ var isPrivilegedUser = function (publicKey, cb) { }); }; +// The limits object contains storage limits for all the publicKey that have paid +// To each key is associated an object containing the 'limit' value and a 'note' explaining that limit var limits = {}; var updateLimits = function (publicKey, cb) { if (typeof cb !== "function") { cb = function () {}; } @@ -490,7 +492,8 @@ var updateLimits = function (publicKey, cb) { limits = json; var l; if (publicKey) { - l = typeof limits[publicKey] === "number" ? limits[publicKey] : DEFAULT_LIMIT; + var limit = limits[publicKey]; + l = limit && typeof limit.limit === "number" ? limit.limit : DEFAULT_LIMIT; } cb(void 0, l); } catch (e) { @@ -507,7 +510,8 @@ var updateLimits = function (publicKey, cb) { req.end(body); }; var getLimit = function (publicKey, cb) { - return void cb(null, typeof limits[publicKey] === "number" ? limits[publicKey] : DEFAULT_LIMIT); + var limit = limits[publicKey]; + return limit && typeof limit.limit === "number" ? limit.limit : DEFAULT_LIMIT; }; var safeMkdir = function (path, cb) {