Use the new format for the storage limits
This commit is contained in:
parent
e123ad0333
commit
d2ba8f1c27
8
rpc.js
8
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 limits = {};
|
||||||
var updateLimits = function (publicKey, cb) {
|
var updateLimits = function (publicKey, cb) {
|
||||||
if (typeof cb !== "function") { cb = function () {}; }
|
if (typeof cb !== "function") { cb = function () {}; }
|
||||||
@ -490,7 +492,8 @@ var updateLimits = function (publicKey, cb) {
|
|||||||
limits = json;
|
limits = json;
|
||||||
var l;
|
var l;
|
||||||
if (publicKey) {
|
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);
|
cb(void 0, l);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@ -507,7 +510,8 @@ var updateLimits = function (publicKey, cb) {
|
|||||||
req.end(body);
|
req.end(body);
|
||||||
};
|
};
|
||||||
var getLimit = function (publicKey, cb) {
|
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) {
|
var safeMkdir = function (path, cb) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user