File tree Expand file tree Collapse file tree 1 file changed +22
-14
lines changed
Expand file tree Collapse file tree 1 file changed +22
-14
lines changed Original file line number Diff line number Diff line change @@ -4,20 +4,28 @@ import "github.com/pkg/errors"
44
55const (
66 applyDepositorsInsertQuery = `
7- INSERT INTO t_identified_validators (
8- f_validator_pubkey,
9- f_pool_name
10- )
11- SELECT DISTINCT
12- t1.f_validator_pubkey,
13- f_pool_name
14- FROM
15- t_beacon_deposits t1
16- RIGHT JOIN
17- t_depositors_insert t2
18- ON
19- t1.f_depositor = t2.f_depositor
20- ON CONFLICT (f_validator_pubkey) DO UPDATE SET f_pool_name = EXCLUDED.f_pool_name;
7+ INSERT INTO t_identified_validators (
8+ f_validator_pubkey,
9+ f_pool_name
10+ )
11+ SELECT DISTINCT
12+ t1.f_validator_pubkey,
13+ t2.f_pool_name
14+ FROM (
15+ SELECT
16+ f_validator_pubkey,
17+ f_depositor,
18+ ROW_NUMBER() OVER (
19+ PARTITION BY f_validator_pubkey
20+ ORDER BY f_block_num DESC
21+ ) as rn
22+ FROM t_beacon_deposits
23+ ) t1
24+ INNER JOIN t_depositors_insert t2
25+ ON t1.f_depositor = t2.f_depositor
26+ WHERE t1.rn = 1
27+ ON CONFLICT (f_validator_pubkey) DO UPDATE SET
28+ f_pool_name = EXCLUDED.f_pool_name;
2129 `
2230)
2331
You can’t perform that action at this time.
0 commit comments