Skip to content
Snippets Groups Projects
Unverified Commit a86503a9 authored by Éloïs's avatar Éloïs
Browse files

[fix] #1190

parent 716ee557
No related branches found
No related tags found
No related merge requests found
...@@ -16,6 +16,7 @@ import {DBMembership} from "./sqliteDAL/MembershipDAL" ...@@ -16,6 +16,7 @@ import {DBMembership} from "./sqliteDAL/MembershipDAL"
import {MerkleDTO} from "../dto/MerkleDTO" import {MerkleDTO} from "../dto/MerkleDTO"
import {CommonConstants} from "../common-libs/constants" import {CommonConstants} from "../common-libs/constants"
import { ProxiesConf } from '../proxy'; import { ProxiesConf } from '../proxy';
import { getOfficialRevocation } from '../common-libs/rawer';
const fs = require('fs') const fs = require('fs')
const path = require('path') const path = require('path')
...@@ -367,6 +368,10 @@ export class FileDAL { ...@@ -367,6 +368,10 @@ export class FileDAL {
return this.iindexDAL.getToBeKickedPubkeys() return this.iindexDAL.getToBeKickedPubkeys()
} }
getRevokedPubkeys() {
return this.mindexDAL.getRevokedPubkeys()
}
async searchJustIdentities(search:string) { async searchJustIdentities(search:string) {
const pendings = await this.idtyDAL.searchThoseMatching(search); const pendings = await this.idtyDAL.searchThoseMatching(search);
const writtens = await this.iindexDAL.searchThoseMatching(search); const writtens = await this.iindexDAL.searchThoseMatching(search);
......
import {SQLiteDriver} from "../drivers/SQLiteDriver"; import {SQLiteDriver} from "../drivers/SQLiteDriver";
import {AbstractSQLite} from "./AbstractSQLite"; import {AbstractSQLite} from "./AbstractSQLite";
import {SandBox} from "./SandBox"; import {SandBox} from "./SandBox";
import { Indexer } from '../../indexer';
const _ = require('underscore'); const _ = require('underscore');
const constants = require('../../constants'); const constants = require('../../constants');
......
...@@ -2,6 +2,8 @@ import {SQLiteDriver} from "../../drivers/SQLiteDriver"; ...@@ -2,6 +2,8 @@ import {SQLiteDriver} from "../../drivers/SQLiteDriver";
import {AbstractIndex} from "../AbstractIndex"; import {AbstractIndex} from "../AbstractIndex";
import {Indexer, MindexEntry} from "../../../indexer"; import {Indexer, MindexEntry} from "../../../indexer";
const _ = require('underscore');
export class MIndexDAL extends AbstractIndex<MindexEntry> { export class MIndexDAL extends AbstractIndex<MindexEntry> {
constructor(driver:SQLiteDriver) { constructor(driver:SQLiteDriver) {
...@@ -70,4 +72,12 @@ export class MIndexDAL extends AbstractIndex<MindexEntry> { ...@@ -70,4 +72,12 @@ export class MIndexDAL extends AbstractIndex<MindexEntry> {
async removeBlock(blockstamp:string) { async removeBlock(blockstamp:string) {
return this.exec('DELETE FROM ' + this.table + ' WHERE written_on = \'' + blockstamp + '\'') return this.exec('DELETE FROM ' + this.table + ' WHERE written_on = \'' + blockstamp + '\'')
} }
async getRevokedPubkeys() {
// All those who has been revoked. Make one result per pubkey.
const revovedMemberships = await this.sqlFind({ revoked_on: { $null: false} });
// Filter on those to be revoked, return their pubkey
return revovedMemberships.map((entry:MindexEntry) => entry.pub);
}
} }
...@@ -62,6 +62,7 @@ export class BlockGenerator { ...@@ -62,6 +62,7 @@ export class BlockGenerator {
const current = await this.dal.getCurrentBlockOrNull(); const current = await this.dal.getCurrentBlockOrNull();
const revocations = await this.dal.getRevocatingMembers(); const revocations = await this.dal.getRevocatingMembers();
const exclusions = await this.dal.getToBeKickedPubkeys(); const exclusions = await this.dal.getToBeKickedPubkeys();
const wereExcludeds = await this.dal.getRevokedPubkeys();
const newCertsFromWoT = await generator.findNewCertsFromWoT(current); const newCertsFromWoT = await generator.findNewCertsFromWoT(current);
const newcomersLeavers = await this.findNewcomersAndLeavers(current, (joinersData:any) => generator.filterJoiners(joinersData)); const newcomersLeavers = await this.findNewcomersAndLeavers(current, (joinersData:any) => generator.filterJoiners(joinersData));
const transactions = await this.findTransactions(current); const transactions = await this.findTransactions(current);
...@@ -88,7 +89,7 @@ export class BlockGenerator { ...@@ -88,7 +89,7 @@ export class BlockGenerator {
}); });
// Revocations // Revocations
// Create the block // Create the block
return this.createBlock(current, joinData, leaveData, newCertsFromWoT, revocations, exclusions, transactions, manualValues); return this.createBlock(current, joinData, leaveData, newCertsFromWoT, revocations, exclusions, wereExcludeds, transactions, manualValues);
} }
private async findNewcomersAndLeavers(current:DBBlock, filteringFunc: (joinData: { [pub:string]: any }) => Promise<{ [pub:string]: any }>) { private async findNewcomersAndLeavers(current:DBBlock, filteringFunc: (joinData: { [pub:string]: any }) => Promise<{ [pub:string]: any }>) {
...@@ -419,7 +420,7 @@ export class BlockGenerator { ...@@ -419,7 +420,7 @@ export class BlockGenerator {
}; };
} }
private async createBlock(current:DBBlock, joinData:any, leaveData:any, updates:any, revocations:any, exclusions:any, transactions:any, manualValues:any) { private async createBlock(current:DBBlock, joinData:any, leaveData:any, updates:any, revocations:any, exclusions:any, wereExcluded:any, transactions:any, manualValues:any) {
if (manualValues && manualValues.excluded) { if (manualValues && manualValues.excluded) {
exclusions = manualValues.excluded; exclusions = manualValues.excluded;
...@@ -434,13 +435,20 @@ export class BlockGenerator { ...@@ -434,13 +435,20 @@ export class BlockGenerator {
let blockLen = 0; let blockLen = 0;
// Revocations have an impact on exclusions // Revocations have an impact on exclusions
revocations.forEach((idty:any) => exclusions.push(idty.pubkey)); revocations.forEach((idty:any) => exclusions.push(idty.pubkey));
// Prevent writing joins/updates for excluded members // Prevent writing joins/updates for members who will be excluded
exclusions = _.uniq(exclusions); exclusions = _.uniq(exclusions);
exclusions.forEach((excluded:any) => { exclusions.forEach((excluded:any) => {
delete updates[excluded]; delete updates[excluded];
delete joinData[excluded]; delete joinData[excluded];
delete leaveData[excluded]; delete leaveData[excluded];
}); });
// Prevent writing joins/updates for excluded members
wereExcluded = _.uniq(wereExcluded);
wereExcluded.forEach((excluded:any) => {
delete updates[excluded];
delete joinData[excluded];
delete leaveData[excluded];
});
_(leaveData).keys().forEach((leaver:any) => { _(leaveData).keys().forEach((leaver:any) => {
delete updates[leaver]; delete updates[leaver];
delete joinData[leaver]; delete joinData[leaver];
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment