Skip to content
Snippets Groups Projects
Commit 9935067f authored by Cédric Moreau's avatar Cédric Moreau
Browse files

[fix] #1014 Disable distance computation for "/wot/requirements-of-pending"

parent 7b5db30c
No related branches found
No related tags found
No related merge requests found
...@@ -154,7 +154,7 @@ export class WOTBinding extends AbstractController { ...@@ -154,7 +154,7 @@ export class WOTBinding extends AbstractController {
async requirementsOfPending(req:any): Promise<HttpRequirements> { async requirementsOfPending(req:any): Promise<HttpRequirements> {
const minsig = ParametersService.getMinSig(req) 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) 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)
const all = await this.BlockchainService.requirementsOfIdentities(identities); const all = await this.BlockchainService.requirementsOfIdentities(identities, false);
if (!all || !all.length) { if (!all || !all.length) {
throw BMAConstants.ERRORS.NO_IDTY_MATCHING_PUB_OR_UID; throw BMAConstants.ERRORS.NO_IDTY_MATCHING_PUB_OR_UID;
} }
......
...@@ -250,12 +250,12 @@ export class BlockchainService extends FIFOService { ...@@ -250,12 +250,12 @@ export class BlockchainService extends FIFOService {
} }
async requirementsOfIdentities(identities:DBIdentity[]) { async requirementsOfIdentities(identities:DBIdentity[], computeDistance = true) {
let all:HttpIdentityRequirement[] = []; let all:HttpIdentityRequirement[] = [];
let current = await this.dal.getCurrentBlockOrNull(); let current = await this.dal.getCurrentBlockOrNull();
for (const obj of identities) { for (const obj of identities) {
try { try {
let reqs = await this.requirementsOfIdentity(obj, current); let reqs = await this.requirementsOfIdentity(obj, current, computeDistance);
all.push(reqs); all.push(reqs);
} catch (e) { } catch (e) {
this.logger.warn(e); this.logger.warn(e);
...@@ -264,7 +264,7 @@ export class BlockchainService extends FIFOService { ...@@ -264,7 +264,7 @@ export class BlockchainService extends FIFOService {
return all; return all;
} }
async requirementsOfIdentity(idty:DBIdentity, current:DBBlock): Promise<HttpIdentityRequirement> { async requirementsOfIdentity(idty:DBIdentity, current:DBBlock, computeDistance = true): Promise<HttpIdentityRequirement> {
// TODO: this is not clear // TODO: this is not clear
let expired = false; let expired = false;
let outdistanced = false; let outdistanced = false;
...@@ -300,7 +300,9 @@ export class BlockchainService extends FIFOService { ...@@ -300,7 +300,9 @@ export class BlockchainService extends FIFOService {
const newLinks = await this.server.generatorNewCertsToLinks(newCerts, updates); const newLinks = await this.server.generatorNewCertsToLinks(newCerts, updates);
const currentTime = current ? current.medianTime : 0; const currentTime = current ? current.medianTime : 0;
certs = await this.getValidCerts(pubkey, newCerts); certs = await this.getValidCerts(pubkey, newCerts);
if (computeDistance) {
outdistanced = await GLOBAL_RULES_HELPERS.isOver3Hops(pubkey, newLinks, someNewcomers, current, this.conf, this.dal); outdistanced = await GLOBAL_RULES_HELPERS.isOver3Hops(pubkey, newLinks, someNewcomers, current, this.conf, this.dal);
}
// Expiration of current membershship // Expiration of current membershship
const currentMembership = await this.dal.mindexDAL.getReducedMS(pubkey); const currentMembership = await this.dal.mindexDAL.getReducedMS(pubkey);
const currentMSN = currentMembership ? parseInt(currentMembership.created_on) : -1; const currentMSN = currentMembership ? parseInt(currentMembership.created_on) : -1;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment