diff --git a/app/controllers/wot.js b/app/controllers/wot.js index 19a1d11e4ea720cbec51ddef84c34ded7b8c8c65..c1ad2d9ca56fc37cf1880f157705c8005d19d080 100644 --- a/app/controllers/wot.js +++ b/app/controllers/wot.js @@ -60,7 +60,7 @@ function WOTBinding (server) { var signed = yield server.dal.certsFrom(idty.pubkey); var validSigned = []; for (let j = 0; j < signed.length; j++) { - let cert = signed[j]; + let cert = _.clone(signed[j]); if (!(excluding && cert.block <= excluding.number)) { cert.idty = yield server.dal.getIdentityByHashOrNull(cert.target); validSigned.push(cert); @@ -260,7 +260,6 @@ function WOTBinding (server) { next('Not a member'); return; } - cert.pubkey = idty.pubkey; cert.uid = idty.uid; cert.isMember = idty.member; cert.wasMember = idty.wasMember; @@ -301,7 +300,7 @@ function WOTBinding (server) { }; idty.certs.forEach(function(cert){ json.certifications.push({ - pubkey: cert.pubkey, + pubkey: cert.from, uid: cert.uid, cert_time: cert.cert_time, isMember: cert.isMember, diff --git a/app/lib/dal/fileDAL.js b/app/lib/dal/fileDAL.js index 6ec7f969089a8aeb01239c9da94368121da0be58..e1adb6573d977f06f4aa95d2f237946d11629348 100644 --- a/app/lib/dal/fileDAL.js +++ b/app/lib/dal/fileDAL.js @@ -40,7 +40,10 @@ module.exports = { // Memory only service dals loki = new lokijs('temp', { autosave: false }); } else { - loki = new lokijs('ucoin', { autosave: true, autosaveInterval: 300 }); + loki = new lokijs(path.join(params.home, 'ucoin.json'), { + autosave: true, + autosaveInterval: 300 + }); } return new FileDAL(profile, params.home, "", params.fs, null, 'fileDal', null, loki); }); diff --git a/app/lib/dal/fileDALs/AbstractLoki.js b/app/lib/dal/fileDALs/AbstractLoki.js index 9b842386c6da223a63a5319cf845a4671b23cc3f..e59d77eaa6ebf73bb10d5d76f45dd5edf4161e6b 100644 --- a/app/lib/dal/fileDALs/AbstractLoki.js +++ b/app/lib/dal/fileDALs/AbstractLoki.js @@ -113,7 +113,11 @@ function AbstractLoki(collection, fileDAL, viewFields, loki) { })[0]; }; - this.lokiSave = (entity) => { + this.lokiSave = (fullEntity) => { + let entity = fullEntity; + if (this.propsToSave) { + entity = _.pick(fullEntity, this.propsToSave || []); + } let existing = this.lokiExisting(entity); if (existing) { if (!fileDAL.parentDAL) { @@ -123,6 +127,7 @@ function AbstractLoki(collection, fileDAL, viewFields, loki) { // Save in fork branch: overrides meta data existing.metaData[that.metaKey()] = _.pick(entity, this.metaProps); } + console.log(existing); collection.update(existing); } else { entity.metaData = {}; @@ -132,6 +137,7 @@ function AbstractLoki(collection, fileDAL, viewFields, loki) { _.pluck(entity, this.metaProps).forEach(function(metaProp){ entity[metaProp] = false; }); + console.log(entity); collection.insert(entity); } return Q(entity); diff --git a/app/lib/dal/fileDALs/CertDAL.js b/app/lib/dal/fileDALs/CertDAL.js index 2c3f425f8e9d950dbed9b002a6d479d686ccaf1e..66968eb3da627b283e1cb5c327ddbc62649b8c45 100644 --- a/app/lib/dal/fileDALs/CertDAL.js +++ b/app/lib/dal/fileDALs/CertDAL.js @@ -20,6 +20,16 @@ function CertDAL(fileDAL, loki) { this.idKeys = ['sig', 'from', 'target']; this.metaProps = ['linked']; + this.propsToSave = [ + 'linked', + 'sig', + 'block_number', + 'block_hash', + 'target', + 'to', + 'from', + 'block' + ]; this.init = () => null; diff --git a/app/lib/dal/fileDALs/IdentityDAL.js b/app/lib/dal/fileDALs/IdentityDAL.js index 61dd80802098554571f12887b40542bc27764ea7..1ebef42221c08bd3fd97e0961a9c5f086731095c 100644 --- a/app/lib/dal/fileDALs/IdentityDAL.js +++ b/app/lib/dal/fileDALs/IdentityDAL.js @@ -19,6 +19,20 @@ function IdentityDAL(fileDAL, loki) { this.idKeys = ['pubkey', 'uid', 'hash']; this.metaProps = ['kick', 'leaving', 'member', 'wasMember', 'written', 'currentMSN', 'revoked']; + this.propsToSave = [ + 'revoked', + 'currentMSN', + 'time', + 'member', + 'kick', + 'leaving', + 'wasMember', + 'pubkey', + 'uid', + 'sig', + 'hash', + 'written' + ]; this.init = () => null; diff --git a/app/lib/dal/fileDALs/LinksDAL.js b/app/lib/dal/fileDALs/LinksDAL.js index be4a81394e5d1171c0e6dc53679a8a9374138d50..31401208a31f08dd1b917a713751faca3121effe 100644 --- a/app/lib/dal/fileDALs/LinksDAL.js +++ b/app/lib/dal/fileDALs/LinksDAL.js @@ -20,6 +20,14 @@ function LinksDAL(fileDAL, loki) { this.idKeys = ['source', 'target', 'block_number', 'block_hash']; this.metaProps = ['obsolete']; + this.propsToSave = [ + 'source', + 'target', + 'timestamp', + 'block_number', + 'block_hash', + 'obsolete' + ]; this.init = () => null; diff --git a/app/lib/dal/fileDALs/MembershipDAL.js b/app/lib/dal/fileDALs/MembershipDAL.js index 4c36fd9b380bedea9e629b85aeba09689c4ec4a6..ad51bc21aa723c4ed1661fff1fa632d888cad0fd 100644 --- a/app/lib/dal/fileDALs/MembershipDAL.js +++ b/app/lib/dal/fileDALs/MembershipDAL.js @@ -21,6 +21,19 @@ function MembershipDAL(fileDAL, loki) { this.idKeys = ['issuer', 'signature']; this.metaProps = ['written']; + this.propsToSave = [ + 'membership', + 'issuer', + 'number', + 'blockNumber', + 'blockHash', + 'userid', + 'certts', + 'block', + 'fpr', + 'written', + 'signature' + ]; this.init = () => null; diff --git a/app/lib/dal/fileDALs/SourcesDAL.js b/app/lib/dal/fileDALs/SourcesDAL.js index 4077b26c57903409825d66847a223da6c268563e..1d0971287c2edb3ece7c561d74348847b960f76e 100644 --- a/app/lib/dal/fileDALs/SourcesDAL.js +++ b/app/lib/dal/fileDALs/SourcesDAL.js @@ -20,6 +20,15 @@ function SourcesDAL(fileDAL, loki) { this.idKeys = ['pubkey', 'type', 'number', 'fingerprint', 'amount']; this.metaProps = ['consumed']; + this.propsToSave = [ + 'pubkey', + 'type', + 'number', + 'fingerprint', + 'amount', + 'block_hash', + 'consumed' + ]; this.init = () => null; diff --git a/app/lib/dal/fileDALs/TxsDAL.js b/app/lib/dal/fileDALs/TxsDAL.js index c34a0e1c3072198c14e916ddea56ead61bb41f6e..fdd9a830aa2c5e8708cd2c6ab10f9ad788f83efd 100644 --- a/app/lib/dal/fileDALs/TxsDAL.js +++ b/app/lib/dal/fileDALs/TxsDAL.js @@ -21,6 +21,22 @@ function TxsDAL(fileDAL, loki) { this.idKeys = ['hash', 'block_number']; this.metaProps = ['written', 'removed']; + this.propsToSave = [ + 'inputs', + 'outputs', + 'issuers', + 'signatories', + 'signatures', + 'comment', + 'hash', + 'version', + 'currency', + 'block_number', + 'time', + 'recipients', + 'written', + 'removed' + ]; this.init = () => null; diff --git a/app/lib/entity/certification.js b/app/lib/entity/certification.js index c641aa2fa8fd8e8763d78c020c37d05a2d987f63..69af04ceb62d12cf230fe2fe92128f976243e225 100644 --- a/app/lib/entity/certification.js +++ b/app/lib/entity/certification.js @@ -11,8 +11,7 @@ var Certification = function(json) { that[key] = json[key]; }); - this.from = this.fromKey = this.pubkey = this.from || this.fromKey || this.pubkey; - this.to = this.toKey = this.to || this.toKey; + this.from = this.pubkey = this.from || this.pubkey; this.block = this.block_number = parseInt(this.block || this.block_number); this.inline = function () { diff --git a/app/lib/entity/identity.js b/app/lib/entity/identity.js index 50712df818644992b086836135211f11a06e3f8d..de3fec8c6b0dc4dfbcc9fdb8558f14738055be0f 100644 --- a/app/lib/entity/identity.js +++ b/app/lib/entity/identity.js @@ -33,7 +33,7 @@ var Identity = function(json) { var others = []; this.certs.forEach(function(cert){ others.push({ - "pubkey": cert.pubkey, + "pubkey": cert.from, "meta": { "block_number": cert.block_number },