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

Merge branch '1.6' into dev

parents 4a173cfc a86503a9
No related branches found
No related tags found
2 merge requests!1220Stable/ws2p v1.1 trymerge,!1208Stable/ws2p v1.1
......@@ -16,6 +16,7 @@ import {DBMembership} from "./sqliteDAL/MembershipDAL"
import {MerkleDTO} from "../dto/MerkleDTO"
import {CommonConstants} from "../common-libs/constants"
import { ProxiesConf } from '../proxy';
import { getOfficialRevocation } from '../common-libs/rawer';
const fs = require('fs')
const path = require('path')
......@@ -367,6 +368,10 @@ export class FileDAL {
return this.iindexDAL.getToBeKickedPubkeys()
}
getRevokedPubkeys() {
return this.mindexDAL.getRevokedPubkeys()
}
async searchJustIdentities(search:string) {
const pendings = await this.idtyDAL.searchThoseMatching(search);
const writtens = await this.iindexDAL.searchThoseMatching(search);
......
import {SQLiteDriver} from "../drivers/SQLiteDriver";
import {AbstractSQLite} from "./AbstractSQLite";
import {SandBox} from "./SandBox";
import { Indexer } from '../../indexer';
const _ = require('underscore');
const constants = require('../../constants');
......
......@@ -2,6 +2,8 @@ import {SQLiteDriver} from "../../drivers/SQLiteDriver";
import {AbstractIndex} from "../AbstractIndex";
import {Indexer, MindexEntry} from "../../../indexer";
const _ = require('underscore');
export class MIndexDAL extends AbstractIndex<MindexEntry> {
constructor(driver:SQLiteDriver) {
......@@ -70,4 +72,12 @@ export class MIndexDAL extends AbstractIndex<MindexEntry> {
async removeBlock(blockstamp:string) {
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 {
const current = await this.dal.getCurrentBlockOrNull();
const revocations = await this.dal.getRevocatingMembers();
const exclusions = await this.dal.getToBeKickedPubkeys();
const wereExcludeds = await this.dal.getRevokedPubkeys();
const newCertsFromWoT = await generator.findNewCertsFromWoT(current);
const newcomersLeavers = await this.findNewcomersAndLeavers(current, (joinersData:any) => generator.filterJoiners(joinersData));
const transactions = await this.findTransactions(current);
......@@ -88,7 +89,7 @@ export class BlockGenerator {
});
// Revocations
// 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 }>) {
......@@ -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) {
exclusions = manualValues.excluded;
......@@ -434,13 +435,20 @@ export class BlockGenerator {
let blockLen = 0;
// Revocations have an impact on exclusions
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.forEach((excluded:any) => {
delete updates[excluded];
delete joinData[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) => {
delete updates[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