mirror of
https://github.com/twisterarmy/twister-html.git
synced 2025-03-12 13:31:14 +00:00
cache pubkeys in browser memory
This commit is contained in:
parent
770d49d3a1
commit
4f4c720202
@ -23,6 +23,7 @@ var _dhtgetPendingMap = {};
|
|||||||
// memory cache for profile and avatar
|
// memory cache for profile and avatar
|
||||||
var _profileMap = {};
|
var _profileMap = {};
|
||||||
var _avatarMap = {};
|
var _avatarMap = {};
|
||||||
|
var _pubkeyMap = {};
|
||||||
|
|
||||||
// number of dhtgets in progress (requests to the daemon)
|
// number of dhtgets in progress (requests to the daemon)
|
||||||
var _dhtgetsInProgress = 0;
|
var _dhtgetsInProgress = 0;
|
||||||
@ -405,13 +406,21 @@ function checkPubkeyExists(username, cbFunc, cbArg) {
|
|||||||
// cbFunc is called as cbFunc(cbArg, pubkey)
|
// cbFunc is called as cbFunc(cbArg, pubkey)
|
||||||
// if user doesn't exist then pubkey.length == 0
|
// if user doesn't exist then pubkey.length == 0
|
||||||
function dumpPubkey(username, cbFunc, cbArg) {
|
function dumpPubkey(username, cbFunc, cbArg) {
|
||||||
twisterRpc("dumppubkey", [username],
|
if( username in _pubkeyMap ) {
|
||||||
function(args, ret) {
|
if( cbFunc )
|
||||||
args.cbFunc(args.cbArg, ret);
|
cbFunc(cbArg, _pubkeyMap[username]);
|
||||||
}, {cbFunc:cbFunc, cbArg:cbArg},
|
} else {
|
||||||
function(args, ret) {
|
twisterRpc("dumppubkey", [username],
|
||||||
alert(polyglot.t("error_connecting_to_daemon"));
|
function(args, ret) {
|
||||||
}, {cbFunc:cbFunc, cbArg:cbArg});
|
if( ret.length > 0 ) {
|
||||||
|
_pubkeyMap[username] = ret;
|
||||||
|
}
|
||||||
|
args.cbFunc(args.cbArg, ret);
|
||||||
|
}, {cbFunc:cbFunc, cbArg:cbArg},
|
||||||
|
function(args, ret) {
|
||||||
|
alert(polyglot.t("error_connecting_to_daemon"));
|
||||||
|
}, {cbFunc:cbFunc, cbArg:cbArg});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// privkey is obtained from wallet db
|
// privkey is obtained from wallet db
|
||||||
|
Loading…
x
Reference in New Issue
Block a user