-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update allDelegates query to include version
- Loading branch information
Showing
1 changed file
with
28 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |