stop returning the hash of all user pins after pinning

the client doesn't use it and it's CPU-intensive
This commit is contained in:
ansuz 2021-06-30 17:20:03 +05:30
parent a77d0420cd
commit 8e725f3d7c
2 changed files with 11 additions and 13 deletions

View File

@ -8,7 +8,7 @@ const nThen = require("nthen");
//const escapeKeyCharacters = Util.escapeKeyCharacters;
const unescapeKeyCharacters = Util.unescapeKeyCharacters;
var sumChannelSizes = function (sizes) {
var sumChannelSizes = function (sizes) { // FIXME this synchronous code could be done by a worker
return Object.keys(sizes).map(function (id) { return sizes[id]; })
.filter(function (x) {
// only allow positive numbers
@ -171,7 +171,7 @@ Pinning.pinChannel = function (Env, safeKey, channels, cb) {
getMultipleFileSize(Env, toStore, function (e, sizes) {
if (typeof(sizes) === 'undefined') { return void cb(e); }
var pinSize = sumChannelSizes(sizes);
var pinSize = sumChannelSizes(sizes); // FIXME don't do this in the main thread...
getFreeSpace(Env, safeKey, function (e, free) {
if (typeof(free) === 'undefined') {
@ -186,7 +186,7 @@ Pinning.pinChannel = function (Env, safeKey, channels, cb) {
toStore.forEach(function (channel) {
session.channels[channel] = true;
});
getHash(Env, safeKey, cb);
cb();
});
});
});
@ -217,7 +217,7 @@ Pinning.unpinChannel = function (Env, safeKey, channels, cb) {
toStore.forEach(function (channel) {
delete session.channels[channel];
});
getHash(Env, safeKey, cb);
cb();
});
});
};
@ -270,9 +270,7 @@ Pinning.resetUserPins = function (Env, safeKey, channelList, cb) {
// update in-memory cache IFF the reset was allowed.
session.channels = pins;
getHash(Env, safeKey, function (e, hash) {
cb(e, hash);
});
cb();
});
});
});

View File

@ -274,9 +274,9 @@ define([
}
var pads = data.pads || data;
s.rpc.pin(pads, function (e, hash) {
s.rpc.pin(pads, function (e) {
if (e) { return void cb({error: e}); }
cb({hash: hash});
cb({});
});
};
@ -289,9 +289,9 @@ define([
if (!s.rpc) { return void cb({error: 'RPC_NOT_READY'}); }
var pads = data.pads || data;
s.rpc.unpin(pads, function (e, hash) {
s.rpc.unpin(pads, function (e) {
if (e) { return void cb({error: e}); }
cb({hash: hash});
cb({});
});
};
@ -394,9 +394,9 @@ define([
if (!store.rpc) { return void cb({error: 'RPC_NOT_READY'}); }
var list = getCanonicalChannelList(false);
store.rpc.reset(list, function (e, hash) {
store.rpc.reset(list, function (e) {
if (e) { return void cb(e); }
cb(null, hash);
cb(null);
});
};