Skip to content

Commit

Permalink
faster reading of definitions of witnesses
Browse files Browse the repository at this point in the history
  • Loading branch information
tonyofbyteball committed Jul 7, 2018
1 parent cdcd9ea commit 88232b6
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions witness_proof.js
Expand Up @@ -70,17 +70,26 @@ function prepareWitnessProof(arrWitnesses, last_stable_mci, handleResult){
AND (unit_authors.definition_chash IS NOT NULL OR address_definition_changes.unit IS NOT NULL) \n\
ORDER BY `level`",
[arrWitnesses],*/
// 1. initial definitions
// 2. address_definition_changes
// 3. revealing changed definitions
"SELECT unit, `level` \n\
FROM unit_authors "+db.forceIndex('unitAuthorsIndexByAddressDefinitionChash')+" \n\
CROSS JOIN units USING(unit) \n\
WHERE address IN(?) AND definition_chash IS NOT NULL AND "+after_last_stable_mci_cond+" AND is_stable=1 AND sequence='good' \n\
WHERE address IN(?) AND definition_chash=address AND "+after_last_stable_mci_cond+" AND is_stable=1 AND sequence='good' \n\
UNION \n\
SELECT unit, `level` \n\
FROM address_definition_changes \n\
CROSS JOIN units USING(unit) \n\
WHERE address_definition_changes.address IN(?) AND "+after_last_stable_mci_cond+" AND is_stable=1 AND sequence='good' \n\
UNION \n\
SELECT units.unit, `level` \n\
FROM address_definition_changes \n\
CROSS JOIN unit_authors USING(address, definition_chash) \n\
CROSS JOIN units ON unit_authors.unit=units.unit \n\
WHERE address_definition_changes.address IN(?) AND "+after_last_stable_mci_cond+" AND is_stable=1 AND sequence='good' \n\
ORDER BY `level`",
[arrWitnesses, arrWitnesses],
[arrWitnesses, arrWitnesses, arrWitnesses],
function(rows){
async.eachSeries(rows, function(row, cb2){
storage.readJoint(db, row.unit, {
Expand Down

0 comments on commit 88232b6

Please sign in to comment.