Skip to content

Commit 62380bb

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 abe85b8 commit 62380bb

File tree

4 files changed

+22
-4
lines changed

4 files changed

+22
-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
@@ -21,6 +21,7 @@
2121
#include "coins.h"
2222
#include <defaultValues.h>
2323
#include "FeeRate.h"
24+
#include "ForkActivation.h"
2425
#include "init.h"
2526
#include "kernel.h"
2627
#include "libzerocoin/bignum.h"

divi/src/version.cpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,29 @@
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"))
1514
return settings.GetArg("-activeversion", 0);
1615

16+
/* On regtest, we set the new protocol as active without any further
17+
ado. This allows proper testing of the changed logic. */
1718
if (Params().NetworkID() == CBaseChainParams::REGTEST)
1819
return MN_REWARD_SCRIPT_VERSION;
1920

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+
2028
return MIN_PEER_PROTO_VERSION_AFTER_ENFORCEMENT;
2129
}

0 commit comments

Comments
 (0)