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

[fix] #1402

parent c1dd0650
No related branches found
No related tags found
No related merge requests found
...@@ -18,6 +18,7 @@ import { FileDAL } from "../dal/fileDAL"; ...@@ -18,6 +18,7 @@ import { FileDAL } from "../dal/fileDAL";
import { DBBlock } from "../db/DBBlock"; import { DBBlock } from "../db/DBBlock";
import { Underscore } from "../common-libs/underscore"; import { Underscore } from "../common-libs/underscore";
import { DataErrors } from "../common-libs/errors"; import { DataErrors } from "../common-libs/errors";
import { Map } from "../common-libs/crypto/map";
const indexer = require("../indexer").Indexer; const indexer = require("../indexer").Indexer;
const constants = require("../constants"); const constants = require("../constants");
...@@ -213,12 +214,21 @@ export class BlockchainContext { ...@@ -213,12 +214,21 @@ export class BlockchainContext {
return this.dal.getCurrentBlockOrNull(); return this.dal.getCurrentBlockOrNull();
} }
async checkHaveEnoughLinks(target: string, newLinks: any): Promise<any> { async checkHaveEnoughLinks(
const links = await this.dal.getValidLinksTo(target); target: string,
let count = links.length; newLinks: Map<string[]>
): Promise<void> {
const existingLinks = await this.dal.getValidLinksTo(target);
const existingIssuers = existingLinks.map((value) => value.issuer);
let count = existingIssuers.length;
if (newLinks[target] && newLinks[target].length) { if (newLinks[target] && newLinks[target].length) {
count += newLinks[target].length; const uniqIssuers = Underscore.uniq(
existingIssuers.concat(newLinks[target])
);
count = uniqIssuers.length;
} }
if (count < this.conf.sigQty) { if (count < this.conf.sigQty) {
throw ( throw (
"Key " + "Key " +
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment