Skip to content

Commit dd917c8

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 74d85c4 commit dd917c8

File tree

4 files changed

+20
-4
lines changed

4 files changed

+20
-4
lines changed

divi/src/ForkActivation.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ const std::unordered_map<Fork, int64_t,std::hash<int>> ACTIVATION_TIMES = {
2727
{Fork::UniformLotteryWinners, unixTimestampForDec31stMidnight},
2828
/* FIXME: Schedule for a real time. */
2929
{Fork::CheckLockTimeVerify, 2000000000},
30+
/** FIXME: Set actual time once scheduled. */
31+
{Fork::CustomRewardAddresses, 2000000000},
3032
};
3133

3234
} // anonymous namespace

divi/src/ForkActivation.h

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

2835
/**

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)