This commit is contained in:
SuriyaR 2019-08-12 19:25:18 +05:30
parent 3f04006453
commit 95377bd380
2 changed files with 99 additions and 45 deletions

View File

@ -741,27 +741,62 @@ export class BlockchainBlockController {
// } // }
BlockchainBlockFetchQuery['TotalCuckoo']=parseInt(BlockchainBlockFetchQuery.TotalDifficultyCuckaroo) + BlockchainBlockFetchQuery['TotalCuckoo']=parseInt(BlockchainBlockFetchQuery.TotalDifficultyCuckaroo) +
parseInt(BlockchainBlockFetchQuery.TotalDifficultyCuckatoo); parseInt(BlockchainBlockFetchQuery.TotalDifficultyCuckatoo);
if (BlockchainBlockFetchQuery.Height <= 1440) { var coin_existence;
BlockchainBlockFetchQuery['BlockReward'] = 200; let DAY_HEIGHT = 1440
} else if (BlockchainBlockFetchQuery.Height <= 2880) { /// Height of the first epic block emission era
BlockchainBlockFetchQuery['BlockReward'] = 180; const BLOCK_ERA_1 = DAY_HEIGHT * 334;
} else if (BlockchainBlockFetchQuery.Height <= 4320) { /// Height of the second epic block emission era
BlockchainBlockFetchQuery['BlockReward'] = 160; const BLOCK_ERA_2 = BLOCK_ERA_1 + (DAY_HEIGHT * 470);
} else if (BlockchainBlockFetchQuery.Height <= 5760) { /// Height of the third epic block emission era
BlockchainBlockFetchQuery['BlockReward'] = 140; const BLOCK_ERA_3 = BLOCK_ERA_2 + (DAY_HEIGHT * 601);
} else if (BlockchainBlockFetchQuery.Height <= 7200) { /// Height of the fourth epic block emission era
BlockchainBlockFetchQuery['BlockReward'] = 120; const BLOCK_ERA_4 = BLOCK_ERA_3 + (DAY_HEIGHT * 800);
} else if (BlockchainBlockFetchQuery.Height <= 8640) { /// Height of the fifth epic block emission era
BlockchainBlockFetchQuery['BlockReward'] = 100; const BLOCK_ERA_5 = BLOCK_ERA_4 + (DAY_HEIGHT * 1019);
} else if (BlockchainBlockFetchQuery.Height <= 10080) { /// After the epic block emission era 6, each era will last 4 years (approximately 1460 days)
BlockchainBlockFetchQuery['BlockReward'] = 80; const BLOCK_ERA_6_ONWARDS = DAY_HEIGHT * 1460;
} else if (BlockchainBlockFetchQuery.Height <= 11520) { /// Block Reward that will be assigned after we change from era 5 to era 6.
BlockchainBlockFetchQuery['BlockReward'] = 60; const BASE_REWARD_ERA_6_ONWARDS = 0.15625;
} else if (BlockchainBlockFetchQuery.Height <= 12960) { /// Compute the total reward generated by each block in a given height.
BlockchainBlockFetchQuery['BlockReward'] = 50; if (BlockchainBlockFetchQuery.Height <= BLOCK_ERA_1) {
} else { BlockchainBlockFetchQuery['BlockReward'] = 16;
BlockchainBlockFetchQuery['BlockReward'] = 25; } else if (BlockchainBlockFetchQuery.Height <= BLOCK_ERA_2) {
} BlockchainBlockFetchQuery['BlockReward'] = 8;
} else if (BlockchainBlockFetchQuery.Height <= BLOCK_ERA_3) {
BlockchainBlockFetchQuery['BlockReward'] = 4;
} else if (BlockchainBlockFetchQuery.Height <= BLOCK_ERA_4) {
BlockchainBlockFetchQuery['BlockReward'] = 2;
} else if (BlockchainBlockFetchQuery.Height <= BLOCK_ERA_5) {
BlockchainBlockFetchQuery['BlockReward'] = 1;
} else {
// After the era 6, we reduce the block rewards by half each 1460 days.
// Minus 1 to include multiples in the same index
// (i.e changes greater than to greater or equals to)
let height_with_offset = BlockchainBlockFetchQuery.Height - (BLOCK_ERA_5 - 1);
let exp = height_with_offset / BLOCK_ERA_6_ONWARDS;
BlockchainBlockFetchQuery['BlockReward'] = BASE_REWARD_ERA_6_ONWARDS / (1 << exp);
}
// if (BlockchainBlockFetchQuery.Height <= 1440) {
// BlockchainBlockFetchQuery['BlockReward'] = 200;
// } else if (BlockchainBlockFetchQuery.Height <= 2880) {
// BlockchainBlockFetchQuery['BlockReward'] = 180;
// } else if (BlockchainBlockFetchQuery.Height <= 4320) {
// BlockchainBlockFetchQuery['BlockReward'] = 160;
// } else if (BlockchainBlockFetchQuery.Height <= 5760) {
// BlockchainBlockFetchQuery['BlockReward'] = 140;
// } else if (BlockchainBlockFetchQuery.Height <= 7200) {
// BlockchainBlockFetchQuery['BlockReward'] = 120;
// } else if (BlockchainBlockFetchQuery.Height <= 8640) {
// BlockchainBlockFetchQuery['BlockReward'] = 100;
// } else if (BlockchainBlockFetchQuery.Height <= 10080) {
// BlockchainBlockFetchQuery['BlockReward'] = 80;
// } else if (BlockchainBlockFetchQuery.Height <= 11520) {
// BlockchainBlockFetchQuery['BlockReward'] = 60;
// } else if (BlockchainBlockFetchQuery.Height <= 12960) {
// BlockchainBlockFetchQuery['BlockReward'] = 50;
// } else {
// BlockchainBlockFetchQuery['BlockReward'] = 25;
// }
if (BlockchainBlockFetchQuery.PreviousId) { if (BlockchainBlockFetchQuery.PreviousId) {
const BlockchainPreviousBlockFetchQuery = await getRepository( const BlockchainPreviousBlockFetchQuery = await getRepository(
@ -1643,24 +1678,33 @@ const BLOCK_ERA_6_ONWARDS = DAY_HEIGHT * 1460;
/// Block Reward that will be assigned after we change from era 5 to era 6. /// Block Reward that will be assigned after we change from era 5 to era 6.
const BASE_REWARD_ERA_6_ONWARDS = 0.15625; const BASE_REWARD_ERA_6_ONWARDS = 0.15625;
let remaining_height = 0;
/// Compute the total reward generated by each block in a given height. /// Compute the total reward generated by each block in a given height.
if (height <= BLOCK_ERA_1) { if (height <= BLOCK_ERA_1) {
coin_existence = 16; coin_existence = height * 16;
} else if (height <= BLOCK_ERA_2) { } else if (height <= BLOCK_ERA_2) {
coin_existence = 8; remaining_height = height - BLOCK_ERA_1;
coin_existence = (16 * BLOCK_ERA_1) + 8 * remaining_height;
} else if (height <= BLOCK_ERA_3) { } else if (height <= BLOCK_ERA_3) {
coin_existence = 4; remaining_height = height - BLOCK_ERA_2;
coin_existence = (16 * BLOCK_ERA_1) + (8 * BLOCK_ERA_2) + 4 * remaining_height;
} else if (height <= BLOCK_ERA_4) { } else if (height <= BLOCK_ERA_4) {
coin_existence = 2; remaining_height = height - BLOCK_ERA_3;
coin_existence = (16 * BLOCK_ERA_1) + (8 * BLOCK_ERA_2) + (4 * BLOCK_ERA_3) + 2 * remaining_height;
} else if (height <= BLOCK_ERA_5) { } else if (height <= BLOCK_ERA_5) {
coin_existence = 1; remaining_height = height - BLOCK_ERA_4;
coin_existence = (16 * BLOCK_ERA_1) + (8 * BLOCK_ERA_2) + (4 * BLOCK_ERA_3) + (2 * BLOCK_ERA_4) +1 * remaining_height;
} else { } else {
// After the era 6, we reduce the block rewards by half each 1460 days. // After the era 6, we reduce the block rewards by half each 1460 days.
// Minus 1 to include multiples in the same index // Minus 1 to include multiples in the same index
// (i.e changes greater than to greater or equals to) // (i.e changes greater than to greater or equals to)
let preious_circulation = (16 * BLOCK_ERA_1) + (8 * BLOCK_ERA_2) + (4 * BLOCK_ERA_3) + (2 * BLOCK_ERA_4) + (1 * BLOCK_ERA_5);
let height_with_offset = height - (BLOCK_ERA_5 - 1); let height_with_offset = height - (BLOCK_ERA_5 - 1);
let exp = height_with_offset / BLOCK_ERA_6_ONWARDS; let exp = height_with_offset / BLOCK_ERA_6_ONWARDS;
coin_existence = BASE_REWARD_ERA_6_ONWARDS / (1 << exp); let reward_emission = BASE_REWARD_ERA_6_ONWARDS / (1 << exp);
coin_existence = preious_circulation + reward_emission ;
} }
letest_block = this.dateDiff(BlockchainLatestBlockQuery[0].timestamp,true); letest_block = this.dateDiff(BlockchainLatestBlockQuery[0].timestamp,true);

View File

@ -175,25 +175,35 @@ export async function universalGetLatestBlockDetails(socket) {
const BLOCK_ERA_6_ONWARDS = DAY_HEIGHT * 1460; const BLOCK_ERA_6_ONWARDS = DAY_HEIGHT * 1460;
/// Block Reward that will be assigned after we change from era 5 to era 6. /// Block Reward that will be assigned after we change from era 5 to era 6.
const BASE_REWARD_ERA_6_ONWARDS = 0.15625; const BASE_REWARD_ERA_6_ONWARDS = 0.15625;
let remaining_height = 0;
/// Compute the total reward generated by each block in a given height. /// Compute the total reward generated by each block in a given height.
if (height <= BLOCK_ERA_1) { if (height <= BLOCK_ERA_1) {
coin_existence = 16; coin_existence = height * 16;
} else if (height <= BLOCK_ERA_2) { } else if (height <= BLOCK_ERA_2) {
coin_existence = 8; remaining_height = height - BLOCK_ERA_1;
} else if (height <= BLOCK_ERA_3) { coin_existence = (16 * BLOCK_ERA_1) + 8 * remaining_height;
coin_existence = 4; } else if (height <= BLOCK_ERA_3) {
} else if (height <= BLOCK_ERA_4) { remaining_height = height - BLOCK_ERA_2;
coin_existence = 2; coin_existence = (16 * BLOCK_ERA_1) + (8 * BLOCK_ERA_2) + 4 * remaining_height;
} else if (height <= BLOCK_ERA_5) { } else if (height <= BLOCK_ERA_4) {
coin_existence = 1; remaining_height = height - BLOCK_ERA_3;
} else { coin_existence = (16 * BLOCK_ERA_1) + (8 * BLOCK_ERA_2) + (4 * BLOCK_ERA_3) + 2 * remaining_height;
// After the era 6, we reduce the block rewards by half each 1460 days. } else if (height <= BLOCK_ERA_5) {
// Minus 1 to include multiples in the same index remaining_height = height - BLOCK_ERA_4;
// (i.e changes greater than to greater or equals to) coin_existence = (16 * BLOCK_ERA_1) + (8 * BLOCK_ERA_2) + (4 * BLOCK_ERA_3) + (2 * BLOCK_ERA_4) +1 * remaining_height;
let height_with_offset = height - (BLOCK_ERA_5 - 1); } else {
let exp = height_with_offset / BLOCK_ERA_6_ONWARDS; // After the era 6, we reduce the block rewards by half each 1460 days.
coin_existence = BASE_REWARD_ERA_6_ONWARDS / (1 << exp); // Minus 1 to include multiples in the same index
} // (i.e changes greater than to greater or equals to)
let preious_circulation = (16 * BLOCK_ERA_1) + (8 * BLOCK_ERA_2) + (4 * BLOCK_ERA_3) + (2 * BLOCK_ERA_4) + (1 * BLOCK_ERA_5);
let height_with_offset = height - (BLOCK_ERA_5 - 1);
let exp = height_with_offset / BLOCK_ERA_6_ONWARDS;
let reward_emission = BASE_REWARD_ERA_6_ONWARDS / (1 << exp);
coin_existence = preious_circulation + reward_emission ;
}
letest_block = dateDiff(BlockchainLatestBlockQuery[0].timestamp, true); letest_block = dateDiff(BlockchainLatestBlockQuery[0].timestamp, true);
letest_block_num = letest_block // "72" letest_block_num = letest_block // "72"