Skip to content

Commit 9fc5e2d

Browse files
authored
Update coinbase consensus for City Chain (#248)
- Planned upgrade to the City Chain network with a consensus change that divides the coinbase reward by 10, at block height 1 111 111. - Approved and merge since this code is now part of the official City Chain node.
1 parent 633119f commit 9fc5e2d

2 files changed

Lines changed: 42 additions & 1 deletion

File tree

src/Networks/Blockcore.Networks.City/Networks/CityMain.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ protected void RegisterRules(IConsensus consensus)
221221
// rules that require the store to be loaded (coinview)
222222
.Register<FetchUtxosetRule>()
223223
.Register<TransactionDuplicationActivationRule>()
224-
.Register<CheckPosUtxosetRule>() // implements BIP68, MaxSigOps and BlockReward calculation
224+
.Register<CityCheckPosUtxosetRule>() // implements BIP68, MaxSigOps and BlockReward calculation
225225
// Place the PosColdStakingRule after the PosCoinviewRule to ensure that all input scripts have been evaluated
226226
// and that the "IsColdCoinStake" flag would have been set by the OP_CHECKCOLDSTAKEVERIFY opcode if applicable.
227227
.Register<PosColdStakingRule>()
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
using Blockcore.Features.Consensus.Rules.UtxosetRules;
2+
using NBitcoin;
3+
4+
namespace City.Networks.Rules
5+
{
6+
/// <summary>
7+
/// Proof of stake override for the coinview rules - BIP68, MaxSigOps and BlockReward checks.
8+
/// The City rule reduces the coinbase reward from 20 to 2 at block height 1 111 111?
9+
/// </summary>
10+
public class CityCheckPosUtxosetRule : CheckPosUtxosetRule
11+
{
12+
private static readonly int REDUCTIONHEIGHT = 1111111;
13+
14+
/// <inheritdoc />
15+
public override Money GetProofOfWorkReward(int height)
16+
{
17+
if (this.IsPremine(height))
18+
return this.consensus.PremineReward;
19+
20+
return this.consensus.ProofOfWorkReward;
21+
}
22+
23+
/// <summary>
24+
/// Gets miner's coin stake reward.
25+
/// </summary>
26+
/// <param name="height">Target block height.</param>
27+
/// <returns>Miner's coin stake reward.</returns>
28+
public override Money GetProofOfStakeReward(int height)
29+
{
30+
if (this.IsPremine(height))
31+
return this.consensus.PremineReward;
32+
33+
if (height > REDUCTIONHEIGHT)
34+
{
35+
return this.consensus.ProofOfStakeReward / 10;
36+
}
37+
38+
return this.consensus.ProofOfStakeReward;
39+
}
40+
}
41+
}

0 commit comments

Comments
 (0)