Skip to content

Commit 0ee4e56

Browse files
committed
Activate new protocol with fork.
This defines a new time-activated "fork", Fork::CustomRewardAddresses. For now, it is scheduled at timestamp 2000000000; that will be set to the actual activation time once it is determined. When this fork becomes active (i.e. the current best block's timestamp goes beyond the activation time), we require peers to use the new protocol version that supports custom reward addresses. The fork has no other (in particular, no consensus-level) consequences.
1 parent 1d1865c commit 0ee4e56

File tree

4 files changed

+21
-5
lines changed

4 files changed

+21
-5
lines changed

divi/src/ForkActivation.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ const std::unordered_map<Fork, int64_t,std::hash<int>> ACTIVATION_TIMES = {
2828
{Fork::UniformLotteryWinners, unixTimestampForDec31stMidnight},
2929
/* FIXME: Schedule for a real time. */
3030
{Fork::CheckLockTimeVerify, 2000000000},
31-
{Fork::DeprecateMasternodes,2000000000}
31+
{Fork::DeprecateMasternodes,2000000000},
32+
/** FIXME: Set actual time once scheduled. */
33+
{Fork::CustomRewardAddresses, 2000000000},
3234
};
3335

3436
const std::unordered_set<Fork, std::hash<int>> REQUIRE_BLOCK_INDEX_CONTEXT = {

divi/src/ForkActivation.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@ enum Fork
2424
UniformLotteryWinners,
2525
CheckLockTimeVerify,
2626
DeprecateMasternodes,
27+
28+
/**
29+
* Custom reward addresses for masternodes. This is activated like other
30+
* forks based on block time; but it only affects the network protocol
31+
* we require from peers, not the actual consensus logic.
32+
*/
33+
CustomRewardAddresses,
2734
};
2835

2936
/**

divi/src/main.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "coins.h"
2323
#include <defaultValues.h>
2424
#include "FeeRate.h"
25+
#include "ForkActivation.h"
2526
#include "init.h"
2627
#include "kernel.h"
2728
#include "masternode-payments.h"

divi/src/version.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
#include <version.h>
22

3+
#include <chain.h>
34
#include <chainparams.h>
5+
#include <ForkActivation.h>
46
#include <Settings.h>
57

8+
extern CChain chainActive;
69
extern Settings& settings;
710

8-
// Note: whenever a protocol update is needed toggle between both implementations (comment out the formerly active one)
9-
// so we can leave the existing clients untouched (old SPORK will stay on so they don't see even older clients).
10-
// Those old clients won't react to the changes of the other (new) SPORK because at the time of their implementation
11-
// it was the one which was commented out
1211
int ActiveProtocol()
1312
{
1413
if (settings.ParameterIsSet("-activeversion"))
@@ -19,5 +18,12 @@ int ActiveProtocol()
1918
if (Params().NetworkID() == CBaseChainParams::REGTEST)
2019
return MN_REWARD_SCRIPT_VERSION;
2120

21+
/* Otherwise, the protocol update is tied to time-based activation of
22+
a network fork (which in fact does not fork consensus but just the
23+
network protocol). */
24+
const CBlockIndex* tip = chainActive.Tip();
25+
if (tip != nullptr && ActivationState(tip).IsActive(Fork::CustomRewardAddresses))
26+
return MN_REWARD_SCRIPT_VERSION;
27+
2228
return MIN_PEER_PROTO_VERSION_AFTER_ENFORCEMENT;
2329
}

0 commit comments

Comments
 (0)