Commit 6cc4ce5d authored by Cédric Moreau's avatar Cédric Moreau

[fix] #1300 Leave membership is stucking the whole blockchain

parent 5b9034ad
......@@ -519,9 +519,19 @@ export class FileDAL {
.value()
}
async findLeavers() {
const mss = await this.msDAL.getPendingOUT();
return _.chain(mss).sortBy((ms:any) => -ms.sigDate).value();
async findLeavers(blockMedianTime = 0) {
const pending = await this.msDAL.getPendingOUT();
const mss = await Promise.all(pending.map(async (p:any) => {
const reduced = await this.mindexDAL.getReducedMS(p.issuer)
if (!reduced || !reduced.chainable_on || blockMedianTime >= reduced.chainable_on || blockMedianTime < constants.TIME_TO_TURN_ON_BRG_107) {
return p
}
return null
}))
return _.chain(mss)
.filter((ms:any) => ms)
.sortBy((ms:any) => -ms.sigDate)
.value();
}
existsNonReplayableLink(from:string, to:string) {
......
......@@ -151,7 +151,7 @@ export class BlockGenerator {
private async findLeavers(current:DBBlock) {
const leaveData: { [pub:string]: any } = {};
const memberships = await this.dal.findLeavers();
const memberships = await this.dal.findLeavers(current && current.medianTime);
const leavers:string[] = [];
memberships.forEach((ms:any) => leavers.push(ms.issuer));
for (const ms of memberships) {
......
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