Fix variable naming

The variable should better reflect what the query is doing.
This commit is contained in:
Tobias Eidelpes 2021-11-21 14:50:27 +01:00
parent d509f430bf
commit 3c3ac01e98

View File

@ -102,8 +102,8 @@ WHERE sig_id <> pk_id;
-- #16.1.5 Get blocks with inputs that have outputs which have already been -- #16.1.5 Get blocks with inputs that have outputs which have already been
-- spent (double-spending) -- spent (double-spending)
-- First, get outputs that have been doubly spent -- First, get outputs that have more than one input
CREATE OR REPLACE VIEW outputs_doubly_spent AS ( CREATE OR REPLACE VIEW outputs_multiple_inputs AS (
SELECT output_id SELECT output_id
FROM non_coinbase_inputs FROM non_coinbase_inputs
JOIN outputs USING(output_id) JOIN outputs USING(output_id)
@ -113,14 +113,14 @@ CREATE OR REPLACE VIEW outputs_doubly_spent AS (
-- Second, get corresponding input_id where the output was first spent -- Second, get corresponding input_id where the output was first spent
CREATE OR REPLACE VIEW inputs_first_spent AS ( CREATE OR REPLACE VIEW inputs_first_spent AS (
SELECT MIN(input_id) AS input_id, output_id SELECT MIN(input_id) AS input_id, output_id
FROM outputs_doubly_spent FROM outputs_multiple_inputs
JOIN non_coinbase_inputs USING(output_id) JOIN non_coinbase_inputs USING(output_id)
GROUP BY output_id GROUP BY output_id
); );
-- Third, combine to get invalid blocks -- Third, combine to get invalid blocks
INSERT INTO temporary_table INSERT INTO temporary_table
SELECT block_id SELECT block_id
FROM outputs_doubly_spent FROM outputs_multiple_inputs
JOIN non_coinbase_inputs USING(output_id) JOIN non_coinbase_inputs USING(output_id)
WHERE input_id NOT IN ( WHERE input_id NOT IN (
SELECT input_id SELECT input_id