diff --git a/app/lib/blockchain/DuniterBlockchain.ts b/app/lib/blockchain/DuniterBlockchain.ts index e7961febd27ab9821272d8a5e95a9c0cf4b5a136..da6a576bab227dfa64c281329176a07889d27a75 100644 --- a/app/lib/blockchain/DuniterBlockchain.ts +++ b/app/lib/blockchain/DuniterBlockchain.ts @@ -143,7 +143,9 @@ export class DuniterBlockchain extends MiscIndexedBlockchain { // BR_G85 if (Indexer.ruleMembershipExcludedIsMember(iindex) === false) throw Error('ruleMembershipExcludedIsMember'); // BR_G86 - if ((await Indexer.ruleToBeKickedArePresent(iindex, dal)) === false) throw Error('ruleToBeKickedArePresent'); + if ((await Indexer.ruleToBeKickedArePresent(iindex, dal)) === false) { + throw Error('ruleToBeKickedArePresent') + } // BR_G103 if (Indexer.ruleTxWritability(sindex) === false) throw Error('ruleTxWritability'); // BR_G87 diff --git a/app/lib/dal/fileDAL.ts b/app/lib/dal/fileDAL.ts index ed49de19ca25646919553c923a144e5638670f44..397f99ae2966bc7c41336b76762a86138a1f08dc 100644 --- a/app/lib/dal/fileDAL.ts +++ b/app/lib/dal/fileDAL.ts @@ -54,6 +54,7 @@ import {NewLogger} from "../logger" const fs = require('fs') const loki = require('lokijs') +const lokiAdapter = require('./lokifsadapater') const path = require('path') const readline = require('readline') const _ = require('underscore'); @@ -104,6 +105,7 @@ export class FileDAL { this.profile = 'DAL' const that = this this.loki = new loki(path.join(this.rootPath, Directory.INDEX_DB_FILE), { + adapter: new lokiAdapter(), autoload: true, autoloadCallback : () => { const dals = [ diff --git a/app/lib/dal/indexDAL/abstract/IIndexDAO.ts b/app/lib/dal/indexDAL/abstract/IIndexDAO.ts index 22ef18d561c5b51851adad9690daa401efc0dfae..d85975ce3a87affd9a6128cdac574e6750e11a15 100644 --- a/app/lib/dal/indexDAL/abstract/IIndexDAO.ts +++ b/app/lib/dal/indexDAL/abstract/IIndexDAO.ts @@ -29,4 +29,6 @@ export interface IIndexDAO extends ReduceableDAO<IindexEntry> { getMembersPubkeys(): Promise<{ pub:string }[]> getToBeKickedPubkeys(): Promise<string[]> + + findAllByWrittenOn(): Promise<IindexEntry[]> } diff --git a/app/lib/dal/indexDAL/loki/LokiIIndex.ts b/app/lib/dal/indexDAL/loki/LokiIIndex.ts index 74f510a23452fd3d96e22ad7d8a9d5ff84605e9f..1179ef77d5bc61258e1e3c494a3c9f90218969e7 100644 --- a/app/lib/dal/indexDAL/loki/LokiIIndex.ts +++ b/app/lib/dal/indexDAL/loki/LokiIIndex.ts @@ -17,6 +17,13 @@ export class LokiIIndex extends LokiPubkeySharingIndex<IindexEntry> implements I return this.findByPub(pub) } + async findAllByWrittenOn(): Promise<IindexEntry[]> { + return this.collection.chain() + .find({}) + .simplesort('writtenOn') + .data() + } + async findByPub(pub: string): Promise<IindexEntry[]> { return this.collection.chain() .find({ pub }) diff --git a/app/lib/dal/indexDAL/loki/LokiPubkeySharingIndex.ts b/app/lib/dal/indexDAL/loki/LokiPubkeySharingIndex.ts index 36236c07fda6d0db7b23fcea0d9916c03d6fc940..5693a0ce96ca266bf46306e07006c1e1183db6c1 100644 --- a/app/lib/dal/indexDAL/loki/LokiPubkeySharingIndex.ts +++ b/app/lib/dal/indexDAL/loki/LokiPubkeySharingIndex.ts @@ -25,12 +25,12 @@ export class LokiPubkeySharingIndex<T extends { written_on:string, writtenOn:num for (const pub of Object.keys(trimmableByPub)) { if (trimmableByPub[pub].length > 1) { // Remove the existing records - for (const t of trimmableByPub[pub]) { - this.collection.remove(t) - } - // Insert a new one that gathers them - const reduced = Indexer.DUP_HELPERS.reduce(trimmableByPub[pub]) - this.collection.insert(reduced) + // for (const t of trimmableByPub[pub]) { + // this.collection.remove(t) + // } + // // Insert a new one that gathers them + // const reduced = Indexer.DUP_HELPERS.reduce(trimmableByPub[pub]) + // this.collection.insert(reduced) } } } diff --git a/app/lib/indexer.ts b/app/lib/indexer.ts index 8e17bf2b6bef25319bf3616dccd73093795ea3cb..11c1f1ffa6c2172c9b93816ba07eae369b0a60ab 100644 --- a/app/lib/indexer.ts +++ b/app/lib/indexer.ts @@ -567,20 +567,20 @@ export class Indexer { // BR_G16 await Indexer.prepareSpeed(HEAD, head, conf) - // // BR_G19 - // await Indexer.prepareIdentitiesAge(iindex, HEAD, HEAD_1, conf, dal); - - // // BR_G22 - // await Indexer.prepareMembershipsAge(mindex, HEAD, HEAD_1, conf, dal); - // - // // BR_G37 - // await Indexer.prepareCertificationsAge(cindex, HEAD, HEAD_1, conf, dal); - // - // // BR_G104 - // await Indexer.ruleIndexCorrectMembershipExpiryDate(HEAD, mindex, dal); - // - // // BR_G105 - // await Indexer.ruleIndexCorrectCertificationExpiryDate(HEAD, cindex, dal); + // BR_G19 + await Indexer.prepareIdentitiesAge(iindex, HEAD, HEAD_1, conf, dal); + + // BR_G22 + await Indexer.prepareMembershipsAge(mindex, HEAD, HEAD_1, conf, dal); + + // BR_G37 + await Indexer.prepareCertificationsAge(cindex, HEAD, HEAD_1, conf, dal); + + // BR_G104 + await Indexer.ruleIndexCorrectMembershipExpiryDate(HEAD, mindex, dal); + + // BR_G105 + await Indexer.ruleIndexCorrectCertificationExpiryDate(HEAD, cindex, dal); return HEAD; } diff --git a/app/lib/other_constants.ts b/app/lib/other_constants.ts index d10528e99d6325e1c5fe5ced474a1164f9795cfc..6fc9b81f4f91aef227edf313f2cbd1530b331053 100644 --- a/app/lib/other_constants.ts +++ b/app/lib/other_constants.ts @@ -14,7 +14,7 @@ export const OtherConstants = { MUTE_LOGS_DURING_UNIT_TESTS: false, - SQL_TRACES: false, + SQL_TRACES: true, BC_EVENT: { SWITCHED: 'switched', diff --git a/app/modules/reapply.ts b/app/modules/reapply.ts index 0fcb1b206d56b29ae4c75cd268b73ff161a4c191..ac58ece38c4b6e54c86c399cd96ad1a50681b7f9 100644 --- a/app/modules/reapply.ts +++ b/app/modules/reapply.ts @@ -34,6 +34,18 @@ module.exports = { await server.disconnect(); } } + }, { + name: 'db-dump', + desc: 'Dump some db data', + preventIfRunning: true, + onDatabaseExecute: async (server:Server, conf:ConfDTO, program:any, params:any) => { + const data = await server.dal.iindexDAL.findAllByWrittenOn() + for (const d of data) { + if (d.pub === "9DDn592RMWfka6fPtTGkmAS54CkYxohDGuk41EECxioD") { + console.log("%s %s", d.pub, d.kick) + } + } + } }] } }