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

fix(1434): put back value of `expires_on`, not `expired_on`

parent 8f15698b
No related branches found
No related tags found
No related merge requests found
......@@ -59,13 +59,20 @@ export class LevelMIndexExpiresOnIndexer extends LevelDBDataIndex<Pubkey[], Mind
}
})
)
// Case 2: expiration REVERT
const values: MindexEntry[] = Underscore.values(newStateByPub).map(entries => reduce(entries))
const byExpiredOn = reduceGroupBy(values, "expired_on")
await Promise.all(Underscore.keys(byExpiredOn)
.map(async expiresOn => this.addAllKeysToExpiresOn(pint(expiresOn), byExpiredOn[expiresOn].map(e => e.pub)))
)
);
// Case 2: REVERT expired = put back the value of `expires_on`
const values: MindexEntry[] = Underscore.values(
newStateByPub
).map((entries) => reduce(entries));
const byExpiresOnForExpired = reduceGroupBy(values, "expires_on");
await Promise.all(
Underscore.keys(byExpiresOnForExpired).map(async (expiresOn) =>
this.addAllKeysToExpiresOn(
pint(expiresOn),
byExpiresOnForExpired[expiresOn].map((e) => e.pub)
)
)
);
}
async addAllKeysToExpiresOn(expiresOn: number, pubkeys: Pubkey[]): Promise<void> {
......@@ -75,7 +82,9 @@ export class LevelMIndexExpiresOnIndexer extends LevelDBDataIndex<Pubkey[], Mind
entry = []
}
for (const pub of pubkeys) {
entry.push(pub)
if (!entry.includes(pub)) {
entry.push(pub);
}
}
await this.put(key, entry)
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment