Skip to content
This repository has been archived by the owner on Jun 11, 2024. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'origin/1.0.0-beta.9' into development
Browse files Browse the repository at this point in the history
  • Loading branch information
MaciejBaj committed Jun 14, 2018
2 parents 8cbf2e6 + c276938 commit 2d2e459
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,23 +72,23 @@ DO $$
-- Calculating total fees of round
fees AS (SELECT sum(fees) AS total, floor(sum(fees) / 101) AS single FROM round),
-- Get last delegate and timestamp of round's last block
last AS (SELECT "publicKey", timestamp FROM filtered_round ORDER BY height DESC LIMIT 1)
last AS (SELECT "publicKey", timestamp FROM round ORDER BY height DESC LIMIT 1)
INSERT INTO rounds_rewards
SELECT
-- Timestamp of last round's block
last.timestamp,
-- Calculating real fee reward for delegate:
-- Rounded fee per delegate + remaining fees if block is last one of round
(fees.single + (CASE WHEN last."publicKey" = filtered_round."publicKey" AND last.timestamp = filtered_round.timestamp THEN (fees.total - fees.single * 101) ELSE 0 END)) AS fees,
(fees.single + (CASE WHEN last."publicKey" = round."publicKey" AND last.timestamp = round.timestamp THEN (fees.total - fees.single * 101) ELSE 0 END)) AS fees,
-- Block reward
filtered_round.reward,
round.reward,
-- Round
ceil(filtered_round.height / 101::float)::int,
ceil(round.height / 101::float)::int,
-- Delegate public key
filtered_round."publicKey"
FROM last, fees, filtered_round
round."publicKey"
FROM last, fees, round
-- Sort fees by block height
ORDER BY filtered_round.height ASC;
ORDER BY round.height ASC;
END LOOP;
RETURN;
END $$;
Expand Down

0 comments on commit 2d2e459

Please sign in to comment.