Skip to content
Snippets Groups Projects
Commit a17a9e96 authored by Michal Zander's avatar Michal Zander
Browse files

Rename file to process_balances

parent d33da28d
No related branches found
No related tags found
2 merge requests!168Update return types: VEST balances should be returned as strings to address JSON limitations,!153New delegations
......@@ -190,80 +190,4 @@ INTO __balance_history, __current_balances;
END
$$;
CREATE OR REPLACE FUNCTION process_block_range_data(IN _from INT, IN _to INT, IN _report_step INT = 1000)
RETURNS VOID
LANGUAGE 'plpgsql' VOLATILE
SET from_collapse_limit = 16
SET join_collapse_limit = 16
SET jit = OFF
AS
$$
DECLARE
_result INT;
BEGIN
--RAISE NOTICE 'Processing delegations, rewards, savings, withdraws';)
--delegations (40,41,62)
--savings (32,33,34,59,55)
--rewards (39,51,52,63,53)
--withdraws (4,20,56)
--hardforks (60)
WITH process_block_range_data_b AS MATERIALIZED
(
SELECT
ov.body_binary::jsonb AS body,
ov.id AS source_op,
ov.block_num as source_op_block,
ov.op_type_id
FROM operations_view ov
WHERE
ov.op_type_id IN (40,41,62,4,20,56,60,77,70,68) AND
ov.block_num BETWEEN _from AND _to
),
insert_balance AS MATERIALIZED
(
SELECT
pbr.source_op,
pbr.source_op_block,
(CASE
WHEN pbr.op_type_id = 40 THEN
process_delegate_vesting_shares_operation(pbr.body, pbr.source_op, pbr.source_op_block)
WHEN pbr.op_type_id = 41 THEN
process_account_create_with_delegation_operation(pbr.body, pbr.source_op, pbr.source_op_block)
WHEN pbr.op_type_id = 62 THEN
process_return_vesting_delegation_operation(pbr.body, pbr.source_op, pbr.source_op_block)
WHEN pbr.op_type_id = 4 THEN
process_withdraw_vesting_operation(pbr.body, (SELECT withdraw_rate FROM btracker_app_status))
WHEN pbr.op_type_id = 20 THEN
process_set_withdraw_vesting_route_operation(pbr.body)
WHEN pbr.op_type_id = 56 THEN
process_fill_vesting_withdraw_operation(pbr.body, (SELECT start_delayed_vests FROM btracker_app_status))
WHEN pbr.op_type_id = 77 AND (SELECT start_delayed_vests FROM btracker_app_status) = TRUE THEN
process_transfer_to_vesting_completed_operation(pbr.body)
WHEN pbr.op_type_id = 70 AND (SELECT start_delayed_vests FROM btracker_app_status) = TRUE THEN
process_delayed_voting_operation(pbr.body)
WHEN pbr.op_type_id = 68 THEN
process_hardfork_hive_operation(pbr.body)
WHEN pbr.op_type_id = 60 THEN
process_hardfork(((pbr.body)->'value'->>'hardfork_id')::INT)
END)
FROM process_block_range_data_b pbr
ORDER BY pbr.source_op_block, pbr.source_op
)
SELECT COUNT(*) INTO _result
FROM insert_balance;
END
$$;
RESET ROLE;
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