Commit 9aba06ac authored by Cédric Moreau's avatar Cédric Moreau
Browse files

[fix] #1164 Docpool sync must also take internal certifications

parent 45ea5453
import { IindexEntry } from './../../../../lib/indexer';
import {AbstractController} from "./AbstractController";
import {BMAConstants} from "../constants";
import {DBIdentity} from "../../../../lib/dal/sqliteDAL/IdentityDAL";
import { IdentityForRequirements } from '../../../../service/BlockchainService';
import {
HttpCert,
HttpCertIdentity, HttpCertifications,
......@@ -153,7 +155,30 @@ export class WOTBinding extends AbstractController {
async requirementsOfPending(req:any): Promise<HttpRequirements> {
const minsig = ParametersService.getMinSig(req)
const identities = await this.server.dal.idtyDAL.query('SELECT i.*, count(c.sig) as nbSig FROM idty i, cert c WHERE c.target = i.hash group by i.hash having nbSig >= ?', minsig)
let identities:IdentityForRequirements[] = await this.server.dal.idtyDAL.query(
'SELECT i.*, count(c.sig) as nbSig ' +
'FROM idty i, cert c ' +
'WHERE c.target = i.hash group by i.hash having nbSig >= ?',
minsig)
const members:IdentityForRequirements[] = (await this.server.dal.idtyDAL.query(
'SELECT i.*, count(c.sig) as nbSig ' +
'FROM i_index i, cert c ' +
'WHERE c.`to` = i.pub group by i.pub having nbSig >= ?',
minsig)).map((i:IindexEntry):IdentityForRequirements => {
return {
hash: i.hash || "",
member: i.member || false,
wasMember: i.wasMember || false,
pubkey: i.pub,
uid: i.uid || "",
buid: i.created_on || "",
sig: i.sig || "",
revocation_sig: "",
revoked: false,
revoked_on: 0
}
})
identities = identities.concat(members)
const all = await this.BlockchainService.requirementsOfIdentities(identities, false);
if (!all || !all.length) {
throw BMAConstants.ERRORS.NO_IDTY_MATCHING_PUB_OR_UID;
......
import { IdentityForRequirements } from './../../../../service/BlockchainService';
import {Server} from "../../../../../server"
import {WS2PReqMapper} from "../interface/WS2PReqMapper"
import {BlockDTO} from "../../../../lib/dto/BlockDTO"
import { IindexEntry } from '../../../../lib/indexer';
export class WS2PReqMapperByServer implements WS2PReqMapper {
......@@ -27,7 +29,30 @@ export class WS2PReqMapperByServer implements WS2PReqMapper {
}
async getRequirementsOfPending(minsig: number): Promise<any> {
const identities = await this.server.dal.idtyDAL.query('SELECT i.*, count(c.sig) as nbSig FROM idty i, cert c WHERE c.target = i.hash group by i.hash having nbSig >= ?', minsig)
let identities:IdentityForRequirements[] = await this.server.dal.idtyDAL.query(
'SELECT i.*, count(c.sig) as nbSig ' +
'FROM idty i, cert c ' +
'WHERE c.target = i.hash group by i.hash having nbSig >= ?',
minsig)
const members:IdentityForRequirements[] = (await this.server.dal.idtyDAL.query(
'SELECT i.*, count(c.sig) as nbSig ' +
'FROM i_index i, cert c ' +
'WHERE c.`to` = i.pub group by i.pub having nbSig >= ?',
minsig)).map((i:IindexEntry):IdentityForRequirements => {
return {
hash: i.hash || "",
member: i.member || false,
wasMember: i.wasMember || false,
pubkey: i.pub,
uid: i.uid || "",
buid: i.created_on || "",
sig: i.sig || "",
revocation_sig: "",
revoked: false,
revoked_on: 0
}
})
identities = identities.concat(members)
const all = await this.server.BlockchainService.requirementsOfIdentities(identities, false)
return {
identities: all
......
import { IdentityForRequirements } from './BlockchainService';
"use strict";
import {Server} from "../../server"
import {GlobalFifoPromise} from "./GlobalFifoPromise"
......@@ -20,6 +21,18 @@ import {OtherConstants} from "../lib/other_constants"
const _ = require('underscore');
const constants = require('../lib/constants');
export interface IdentityForRequirements {
hash:string
member:boolean
wasMember:boolean
pubkey:string
uid:string
buid:string
sig:string
revocation_sig:string
revoked:boolean
revoked_on:number
}
export class BlockchainService extends FIFOService {
mainContext:BlockchainContext
......@@ -234,7 +247,7 @@ export class BlockchainService extends FIFOService {
}
async requirementsOfIdentities(identities:DBIdentity[], computeDistance = true) {
async requirementsOfIdentities(identities:IdentityForRequirements[], computeDistance = true) {
let all:HttpIdentityRequirement[] = [];
let current = await this.dal.getCurrentBlockOrNull();
for (const obj of identities) {
......@@ -248,7 +261,7 @@ export class BlockchainService extends FIFOService {
return all;
}
async requirementsOfIdentity(idty:DBIdentity, current:DBBlock, computeDistance = true): Promise<HttpIdentityRequirement> {
async requirementsOfIdentity(idty:IdentityForRequirements, current:DBBlock, computeDistance = true): Promise<HttpIdentityRequirement> {
// TODO: this is not clear
let expired = false;
let outdistanced = false;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment