Remove Storage and Profile, Move folders, add EncryptedInsightStorage

This commit is contained in:
Esteban Ordano 2014-10-24 12:24:44 -03:00
commit 61b677498b
20 changed files with 374 additions and 1067 deletions

View file

@ -173,12 +173,14 @@ Wallet.COPAYER_PAIR_LIMITS = {
12: 1,
};
Wallet.getStorageKey = function(str) {
return 'wallet::' + str;
};
Wallet.prototype.getStorageKey = function() {
return Wallet.getStorageKey(this.getId());
};
/* for stubbing */
Wallet._newInsight = function(opts) {
return new Insight(opts);
@ -219,27 +221,6 @@ Wallet.getMaxRequiredCopayers = function(totalCopayers) {
return Wallet.COPAYER_PAIR_LIMITS[totalCopayers];
};
/**
* delete
*
* @param walletId
* @param storage
* @param cb
* @return {undefined}
*/
// Wallet.delete = function(walletId, storage, cb) {
// preconditions.checkArgument(cb);
// storage.deletePrefix(Wallet.getStorageKey(walletId), function(err) {
// if (err && err.message != 'not found') return cb(err);
// storage.deletePrefix(walletId + '::', function(err) {
// if (err && err.message != 'not found') return cb(err);
// return cb();
// });
// });
// };
//
/**
* @desc obtain network name from serialized wallet
* @param {Object} wallet object
@ -601,11 +582,14 @@ Wallet.prototype._onAddressBook = function(senderId, data) {
* @desc Updates the wallet's last modified timestamp and triggers a save
* @param {number} ts - the timestamp
*/
Wallet.prototype.updateTimestamp = function(ts) {
Wallet.prototype.updateTimestamp = function(ts, callback) {
preconditions.checkArgument(ts);
preconditions.checkArgument(_.isNumber(ts));
this.lastTimestamp = ts;
// we dont store here
if (callback) {
return callback(null);
}
};
/**
@ -825,13 +809,10 @@ Wallet.prototype._lockIncomming = function() {
this.network.lockIncommingConnections(this.publicKeyRing.getAllCopayerIds());
};
Wallet.prototype._setBlockchainListeners = function() {
var self = this;
self.blockchain.removeAllListeners();
log.debug('Setting Blockchain listeners for', this.getId());
self.blockchain.on('reconnect', function(attempts) {
log.debug('Wallet:' + self.id + 'blockchain reconnect event');
@ -1018,8 +999,6 @@ Wallet.fromUntrustedObj = function(obj, readOpts) {
return Wallet.fromObj(o,readOpts);
};
/**
* @desc Retrieve the wallet state from a trusted object
*
@ -1110,15 +1089,6 @@ Wallet.fromObj = function(o, readOpts) {
return new Wallet(opts);
};
/**
* @desc Return a base64 encrypted version of the wallet
* @return {string} base64 encoded string
*/
// Wallet.prototype.export = function() {
// var walletObj = this.toObj();
// return this.storage.encrypt(walletObj);
// };
/**
* @desc Send a message to other peers
* @param {string[]} recipients - the pubkey of the recipients of the message