Skip to content

Commit

Permalink
update allDelegates query to include version
Browse files Browse the repository at this point in the history
  • Loading branch information
tyler17 committed Oct 3, 2024
1 parent fa9daf2 commit ba565d1
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions migrations/076-new-all-delegates.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
-- Drop existing functions
DROP FUNCTION IF EXISTS dschief.all_delegates();
DROP FUNCTION IF EXISTS api.all_delegates();

CREATE OR REPLACE FUNCTION dschief.all_delegates()
RETURNS TABLE (
delegate character varying(66),
vote_delegate character varying(66),
delegate_version int
) AS $$
SELECT delegate, vote_delegate, delegate_version
FROM dschief.vote_delegate_created_event
$$ LANGUAGE sql STABLE STRICT;


--This query would be called by allDelegates() in the sdk
CREATE OR REPLACE FUNCTION api.all_delegates()
RETURNS TABLE (
delegate character varying(66),
vote_delegate character varying(66),
delegate_version int,
block_timestamp TIMESTAMP WITH TIME ZONE
) AS $$
SELECT delegate, vote_delegate, delegate_version, b.timestamp
FROM dschief.vote_delegate_created_event d
LEFT JOIN vulcan2x.block b
ON d.block_id = b.id;
$$ LANGUAGE sql STABLE STRICT;

0 comments on commit ba565d1

Please sign in to comment.