Commit 794e510a authored by Kalinka's avatar Kalinka

Controller/BlockController.php:

  - use getRewardByHeight instead of OTF calculation
wallet_additions.sql:
  - add getRewardByHeight for Burst and Boom
parent 1c7759c0
......@@ -15,7 +15,7 @@ class BlockController extends AbstractController
const BlockListByIds = 'SELECT b.height,
CAST(b.id AS UNSIGNED) AS id,
b.timestamp + 1407722400 AS unixtime,
FLOOR(POW(0.95,FLOOR(b.height/10800))*10000) AS reward,
getRewardByHeight(b.height) AS reward,
FORMAT(b.total_fee / 100000000, 2) AS tx_fee,
FORMAT(b.total_amount / 100000000, 2) AS sent,
bi.tx_count AS tx_count,
......@@ -47,7 +47,7 @@ class BlockController extends AbstractController
b.payload_length AS size,
b.nonce,
b.version,
FLOOR(pow(0.95,FLOOR(b.height/10800))*10000) AS reward,
getRewardByHeight(b.height) AS reward,
b.block_signature,
CAST(b.previous_block_id AS UNSIGNED) AS previous_block_id,
CAST(nb.id AS UNSIGNED) AS next_block_id,
......@@ -63,8 +63,8 @@ class BlockController extends AbstractController
const BlockDetailsHeight = ' SELECT CAST(b.id AS UNSIGNED) AS id,
b.height,
bi.tx_count AS tx_count,
FORMAT(b.total_amount / 100000000, 2) AS sent,
FORMAT(b.total_fee / 100000000, 2) AS tx_fee,
FORMAT(b.total_amount / 1000 000 00, 2) AS sent,
FORMAT(b.total_fee / 100 000 000, 2) AS tx_fee,
b.timestamp + 1407722400 AS unixtime,
CAST(bi.generator_id AS UNSIGNED) AS forger,
af.name AS forger_name,
......@@ -75,7 +75,7 @@ class BlockController extends AbstractController
b.payload_length AS size,
b.nonce,
b.version,
FLOOR(pow(0.95,FLOOR(b.height/10800))*10000) AS reward,
getRewardByHeight(b.height) AS reward,
b.block_signature,
CAST(b.previous_block_id AS UNSIGNED) AS previous_block_id,
CAST(nb.id AS UNSIGNED) AS next_block_id,
......
......@@ -67,6 +67,36 @@ DELIMITER ;
-- run "php bin/console explorer:import:blockinfo" afterwards
-- Burstcoin
DELIMITER $$
CREATE FUNCTION getRewardByHeight(in_height bigint(20))
RETURNS INT(5) DETERMINISTIC
BEGIN
RETURN FLOOR(POW(0.95,FLOOR(in_height/10800))*10000);
END$$
-- Booncoin
DELIMITER $$
CREATE FUNCTION getRewardByHeight(in_height bigint(20))
RETURNS BIGINT(20) DETERMINISTIC
BEGIN
DECLARE counter, ratio, reward BIGINT(20);
SET counter = (525000 - 55500);
SET reward = 20000000000;
SELECT b.ratio INTO ratio FROM block b WHERE b.height = in_height;
IF in_height = 0 OR in_height > 20180768 THEN SET reward = 0;
ELSEIF in_height >= 18622075 THEN SET reward = 1;
ELSE
WHILE in_height > counter DO
SET counter = counter + 525000;
SET reward = reward / 2;
END WHILE;
END IF;
RETURN reward * ratio / 100;
END$$
DELIMITER ;
DELIMITER $$
CREATE PROCEDURE cache_all()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment