mediachain / concat

Mediachain daemons
MIT License
42 stars 13 forks source link

Deduplicate wkis in mcq.StatementRefs #107

Closed vyzo closed 7 years ago

vyzo commented 7 years ago

This fixes a subtle issue with duplicate wkis in compound statements: It is possible for a compound statement to include simple statements which refer to the same wki, which would be included multiple times in the list returned by mcq.StatementRef. As a result, the same statement would be mapped to the same wki multiple times in the Refs table. This would create garbage in the db and have the unfortunate side effect of having the same statement appear multiple times in a query result set even when querying for a single wki.

The PR fixes this by constructing a set for compound statements, which deduplicates the wkis. Measurements indicate no performance penalty for compound statement processing.

PS: Also added dedup for simple statements, to protect from faulty publishers who don't dedup their references. Performance degradation for simple statements is also neglible.