diff --git a/app/modules/bma/lib/controllers/wot.ts b/app/modules/bma/lib/controllers/wot.ts index 163591ce6fff53cb34a1a2c569f81208dbc315a7..51d1768999c3740ca49e6f2f2e4dc03b3ae0d591 100644 --- a/app/modules/bma/lib/controllers/wot.ts +++ b/app/modules/bma/lib/controllers/wot.ts @@ -154,7 +154,7 @@ 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) - const all = await this.BlockchainService.requirementsOfIdentities(identities); + const all = await this.BlockchainService.requirementsOfIdentities(identities, false); if (!all || !all.length) { throw BMAConstants.ERRORS.NO_IDTY_MATCHING_PUB_OR_UID; } diff --git a/app/service/BlockchainService.ts b/app/service/BlockchainService.ts index 5ca05d175d313f446e26211c5d679701802c08d8..5dd935434a35ea18e9a0b8e14a788fb9462163d3 100644 --- a/app/service/BlockchainService.ts +++ b/app/service/BlockchainService.ts @@ -250,12 +250,12 @@ export class BlockchainService extends FIFOService { } - async requirementsOfIdentities(identities:DBIdentity[]) { + async requirementsOfIdentities(identities:DBIdentity[], computeDistance = true) { let all:HttpIdentityRequirement[] = []; let current = await this.dal.getCurrentBlockOrNull(); for (const obj of identities) { try { - let reqs = await this.requirementsOfIdentity(obj, current); + let reqs = await this.requirementsOfIdentity(obj, current, computeDistance); all.push(reqs); } catch (e) { this.logger.warn(e); @@ -264,7 +264,7 @@ export class BlockchainService extends FIFOService { 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 let expired = false; let outdistanced = false; @@ -300,7 +300,9 @@ export class BlockchainService extends FIFOService { const newLinks = await this.server.generatorNewCertsToLinks(newCerts, updates); const currentTime = current ? current.medianTime : 0; certs = await this.getValidCerts(pubkey, newCerts); - outdistanced = await GLOBAL_RULES_HELPERS.isOver3Hops(pubkey, newLinks, someNewcomers, current, this.conf, this.dal); + if (computeDistance) { + outdistanced = await GLOBAL_RULES_HELPERS.isOver3Hops(pubkey, newLinks, someNewcomers, current, this.conf, this.dal); + } // Expiration of current membershship const currentMembership = await this.dal.mindexDAL.getReducedMS(pubkey); const currentMSN = currentMembership ? parseInt(currentMembership.created_on) : -1;