Skip to content

Commit 3a6cf2d

Browse files
committed
Update algo swap code for develop undo rename of params
1 parent dba860a commit 3a6cf2d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+395
-344
lines changed

src/addrdb.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ bool SerializeDB(Stream& stream, const Data& data)
2424
// Write and commit header, data
2525
try {
2626
CHashWriter hasher(SER_DISK, CLIENT_VERSION);
27-
stream << FLATDATA(Params().MessageStart()) << data;
28-
hasher << FLATDATA(Params().MessageStart()) << data;
27+
stream << FLATDATA(GetParams().MessageStart()) << data;
28+
hasher << FLATDATA(GetParams().MessageStart()) << data;
2929
stream << hasher.GetHash();
3030
} catch (const std::exception& e) {
3131
return error("%s: Serialize or I/O error - %s", __func__, e.what());
@@ -70,7 +70,7 @@ bool DeserializeDB(Stream& stream, Data& data, bool fCheckSum = true)
7070
unsigned char pchMsgTmp[4];
7171
verifier >> FLATDATA(pchMsgTmp);
7272
// ... verify the network matches ours
73-
if (memcmp(pchMsgTmp, Params().MessageStart(), sizeof(pchMsgTmp)))
73+
if (memcmp(pchMsgTmp, GetParams().MessageStart(), sizeof(pchMsgTmp)))
7474
return error("%s: Invalid network magic number", __func__);
7575

7676
// de-serialize data

src/assets/assets.cpp

Lines changed: 37 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3080,7 +3080,7 @@ bool CheckReissueBurnTx(const CTxOut& txOut)
30803080
return false;
30813081

30823082
// Check destination address is the correct burn address
3083-
if (EncodeDestination(destination) != Params().ReissueAssetBurnAddress())
3083+
if (EncodeDestination(destination) != GetParams().ReissueAssetBurnAddress())
30843084
return false;
30853085

30863086
return true;
@@ -3549,47 +3549,47 @@ void GetAllMyAssets(CWallet* pwallet, std::vector<std::string>& names, int nMinC
35493549

35503550
CAmount GetIssueAssetBurnAmount()
35513551
{
3552-
return Params().IssueAssetBurnAmount();
3552+
return GetParams().IssueAssetBurnAmount();
35533553
}
35543554

35553555
CAmount GetReissueAssetBurnAmount()
35563556
{
3557-
return Params().ReissueAssetBurnAmount();
3557+
return GetParams().ReissueAssetBurnAmount();
35583558
}
35593559

35603560
CAmount GetIssueSubAssetBurnAmount()
35613561
{
3562-
return Params().IssueSubAssetBurnAmount();
3562+
return GetParams().IssueSubAssetBurnAmount();
35633563
}
35643564

35653565
CAmount GetIssueUniqueAssetBurnAmount()
35663566
{
3567-
return Params().IssueUniqueAssetBurnAmount();
3567+
return GetParams().IssueUniqueAssetBurnAmount();
35683568
}
35693569

35703570
CAmount GetIssueMsgChannelAssetBurnAmount()
35713571
{
3572-
return Params().IssueMsgChannelAssetBurnAmount();
3572+
return GetParams().IssueMsgChannelAssetBurnAmount();
35733573
}
35743574

35753575
CAmount GetIssueQualifierAssetBurnAmount()
35763576
{
3577-
return Params().IssueQualifierAssetBurnAmount();
3577+
return GetParams().IssueQualifierAssetBurnAmount();
35783578
}
35793579

35803580
CAmount GetIssueSubQualifierAssetBurnAmount()
35813581
{
3582-
return Params().IssueSubQualifierAssetBurnAmount();
3582+
return GetParams().IssueSubQualifierAssetBurnAmount();
35833583
}
35843584

35853585
CAmount GetIssueRestrictedAssetBurnAmount()
35863586
{
3587-
return Params().IssueRestrictedAssetBurnAmount();
3587+
return GetParams().IssueRestrictedAssetBurnAmount();
35883588
}
35893589

35903590
CAmount GetAddNullQualifierTagBurnAmount()
35913591
{
3592-
return Params().AddNullQualifierTagBurnAmount();
3592+
return GetParams().AddNullQualifierTagBurnAmount();
35933593
}
35943594

35953595
CAmount GetBurnAmount(const int nType)
@@ -3636,27 +3636,27 @@ std::string GetBurnAddress(const AssetType type)
36363636
{
36373637
switch (type) {
36383638
case AssetType::ROOT:
3639-
return Params().IssueAssetBurnAddress();
3639+
return GetParams().IssueAssetBurnAddress();
36403640
case AssetType::SUB:
3641-
return Params().IssueSubAssetBurnAddress();
3641+
return GetParams().IssueSubAssetBurnAddress();
36423642
case AssetType::MSGCHANNEL:
3643-
return Params().IssueMsgChannelAssetBurnAddress();
3643+
return GetParams().IssueMsgChannelAssetBurnAddress();
36443644
case AssetType::OWNER:
36453645
return "";
36463646
case AssetType::UNIQUE:
3647-
return Params().IssueUniqueAssetBurnAddress();
3647+
return GetParams().IssueUniqueAssetBurnAddress();
36483648
case AssetType::VOTE:
36493649
return "";
36503650
case AssetType::REISSUE:
3651-
return Params().ReissueAssetBurnAddress();
3651+
return GetParams().ReissueAssetBurnAddress();
36523652
case AssetType::QUALIFIER:
3653-
return Params().IssueQualifierAssetBurnAddress();
3653+
return GetParams().IssueQualifierAssetBurnAddress();
36543654
case AssetType::SUB_QUALIFIER:
3655-
return Params().IssueSubQualifierAssetBurnAddress();
3655+
return GetParams().IssueSubQualifierAssetBurnAddress();
36563656
case AssetType::RESTRICTED:
3657-
return Params().IssueRestrictedAssetBurnAddress();
3657+
return GetParams().IssueRestrictedAssetBurnAddress();
36583658
case AssetType::NULL_ADD_QUALIFIER:
3659-
return Params().AddNullQualifierTagBurnAddress();
3659+
return GetParams().AddNullQualifierTagBurnAddress();
36603660
default:
36613661
return "";
36623662
}
@@ -4093,7 +4093,7 @@ bool CreateReissueAssetTransaction(CWallet* pwallet, CCoinControl& coinControl,
40934093
}
40944094

40954095
// Get the script for the burn address
4096-
CScript scriptPubKeyBurn = GetScriptForDestination(DecodeDestination(Params().ReissueAssetBurnAddress()));
4096+
CScript scriptPubKeyBurn = GetScriptForDestination(DecodeDestination(GetParams().ReissueAssetBurnAddress()));
40974097

40984098
// Create and send the transaction
40994099
CRecipient recipient = {scriptPubKeyBurn, burnAmount, fSubtractFeeFromAmount};
@@ -5094,7 +5094,7 @@ bool ContextualCheckVerifierString(CAssetsCache* cache, const std::string& verif
50945094
}
50955095
}
50965096

5097-
bool ContextualCheckTransferAsset(CAssetsCache* assetCache, const CAssetTransfer& transfer, const std::string& address, std::string& strError)
5097+
bool ContextualCheckTransferAsset(CAssetsCache* assetCache, const CAssetTransfer& transfer, const std::string& address, std::string& strError, AssetInfo* assetInfo)
50985098
{
50995099
strError = "";
51005100
AssetType assetType;
@@ -5103,7 +5103,22 @@ bool ContextualCheckTransferAsset(CAssetsCache* assetCache, const CAssetTransfer
51035103
return false;
51045104
}
51055105

5106+
if (assetInfo) {
5107+
if (transfer.nAmount <= 0) {
5108+
if (assetInfo->fFromMempool) {
5109+
strError = "Invalid parameter: asset amount can't be equal to or less than zero.";
5110+
return false;
5111+
}
5112+
5113+
if (assetInfo->nTimeAdded >= GetParams().X16RV2ActivationTime()) {
5114+
strError = "Invalid parameter: asset amount can't be equal to or less than zero.";
5115+
return false;
5116+
}
5117+
}
5118+
}
5119+
51065120
if (AreMessagingDeployed()) {
5121+
// This is for the current testnet6 only.
51075122
if (transfer.nAmount <= 0) {
51085123
strError = "Invalid parameter: asset amount can't be equal to or less than zero.";
51095124
return false;
@@ -5307,7 +5322,7 @@ bool CheckReissueAsset(const CReissueAsset& asset, std::string& strError)
53075322
/// -------- TESTNET ONLY ---------- ///
53085323
// Testnet has a couple blocks that have invalid nReissue values before constriants were created
53095324
bool fSkip = false;
5310-
if (Params().NetworkIDString() == CBaseChainParams::TESTNET) {
5325+
if (GetParams().NetworkIDString() == CBaseChainParams::TESTNET) {
53115326
if (asset.strName == "GAMINGWEB" && asset.nReissuable == 109) {
53125327
fSkip = true;
53135328
} else if (asset.strName == "UINT8" && asset.nReissuable == -47) {

src/assets/assets.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,7 @@ bool ContextualCheckGlobalAssetTxOut(const CTxOut& txout, CAssetsCache* assetCac
565565
bool ContextualCheckVerifierAssetTxOut(const CTxOut& txout, CAssetsCache* assetCache, std::string& strError);
566566
bool ContextualCheckVerifierString(CAssetsCache* cache, const std::string& verifier, const std::string& check_address, std::string& strError, ErrorReport* errorReport = nullptr);
567567
bool ContextualCheckNewAsset(CAssetsCache* assetCache, const CNewAsset& asset, std::string& strError, bool fCheckMempool = false);
568-
bool ContextualCheckTransferAsset(CAssetsCache* assetCache, const CAssetTransfer& transfer, const std::string& address, std::string& strError);
568+
bool ContextualCheckTransferAsset(CAssetsCache* assetCache, const CAssetTransfer& transfer, const std::string& address, std::string& strError, AssetInfo* assetInfo = nullptr);
569569
bool ContextualCheckReissueAsset(CAssetsCache* assetCache, const CReissueAsset& reissue_asset, std::string& strError, const CTransaction& tx);
570570
bool ContextualCheckReissueAsset(CAssetsCache* assetCache, const CReissueAsset& reissue_asset, std::string& strError);
571571
bool ContextualCheckUniqueAssetTx(CAssetsCache* assetCache, std::string& strError, const CTransaction& tx);

src/assets/messages.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,11 +197,11 @@ bool ScanForMessageChannels(std::string& strError)
197197
return false;
198198
}
199199

200-
CBlockIndex* blockIndex = chainActive[Params().GetAssetActivationHeight()];
200+
CBlockIndex* blockIndex = chainActive[GetParams().GetAssetActivationHeight()];
201201

202202
while (blockIndex) {
203203
CBlock block;
204-
if (!ReadBlockFromDisk(block, blockIndex, Params().GetConsensus())) {
204+
if (!ReadBlockFromDisk(block, blockIndex, GetParams().GetConsensus())) {
205205
strError = "Block not found on disk";
206206
return false;
207207
}

src/base58.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -231,13 +231,13 @@ class CRavenAddressVisitor : public boost::static_visitor<bool>
231231

232232
bool CRavenAddress::Set(const CKeyID& id)
233233
{
234-
SetData(Params().Base58Prefix(CChainParams::PUBKEY_ADDRESS), &id, 20);
234+
SetData(GetParams().Base58Prefix(CChainParams::PUBKEY_ADDRESS), &id, 20);
235235
return true;
236236
}
237237

238238
bool CRavenAddress::Set(const CScriptID& id)
239239
{
240-
SetData(Params().Base58Prefix(CChainParams::SCRIPT_ADDRESS), &id, 20);
240+
SetData(GetParams().Base58Prefix(CChainParams::SCRIPT_ADDRESS), &id, 20);
241241
return true;
242242
}
243243

@@ -248,7 +248,7 @@ bool CRavenAddress::Set(const CTxDestination& dest)
248248

249249
bool CRavenAddress::IsValid() const
250250
{
251-
return IsValid(Params());
251+
return IsValid(GetParams());
252252
}
253253

254254
bool CRavenAddress::IsValid(const CChainParams& params) const
@@ -265,9 +265,9 @@ CTxDestination CRavenAddress::Get() const
265265
return CNoDestination();
266266
uint160 id;
267267
memcpy(&id, vchData.data(), 20);
268-
if (vchVersion == Params().Base58Prefix(CChainParams::PUBKEY_ADDRESS))
268+
if (vchVersion == GetParams().Base58Prefix(CChainParams::PUBKEY_ADDRESS))
269269
return CKeyID(id);
270-
else if (vchVersion == Params().Base58Prefix(CChainParams::SCRIPT_ADDRESS))
270+
else if (vchVersion == GetParams().Base58Prefix(CChainParams::SCRIPT_ADDRESS))
271271
return CScriptID(id);
272272
else
273273
return CNoDestination();
@@ -277,11 +277,11 @@ bool CRavenAddress::GetIndexKey(uint160& hashBytes, int& type) const
277277
{
278278
if (!IsValid()) {
279279
return false;
280-
} else if (vchVersion == Params().Base58Prefix(CChainParams::PUBKEY_ADDRESS)) {
280+
} else if (vchVersion == GetParams().Base58Prefix(CChainParams::PUBKEY_ADDRESS)) {
281281
memcpy(&hashBytes, &vchData[0], 20);
282282
type = 1;
283283
return true;
284-
} else if (vchVersion == Params().Base58Prefix(CChainParams::SCRIPT_ADDRESS)) {
284+
} else if (vchVersion == GetParams().Base58Prefix(CChainParams::SCRIPT_ADDRESS)) {
285285
memcpy(&hashBytes, &vchData[0], 20);
286286
type = 2;
287287
return true;
@@ -293,7 +293,7 @@ bool CRavenAddress::GetIndexKey(uint160& hashBytes, int& type) const
293293
void CRavenSecret::SetKey(const CKey& vchSecret)
294294
{
295295
assert(vchSecret.IsValid());
296-
SetData(Params().Base58Prefix(CChainParams::SECRET_KEY), vchSecret.begin(), vchSecret.size());
296+
SetData(GetParams().Base58Prefix(CChainParams::SECRET_KEY), vchSecret.begin(), vchSecret.size());
297297
if (vchSecret.IsCompressed())
298298
vchData.push_back(1);
299299
}
@@ -309,7 +309,7 @@ CKey CRavenSecret::GetKey()
309309
bool CRavenSecret::IsValid() const
310310
{
311311
bool fExpectedFormat = vchData.size() == 32 || (vchData.size() == 33 && vchData[32] == 1);
312-
bool fCorrectVersion = vchVersion == Params().Base58Prefix(CChainParams::SECRET_KEY);
312+
bool fCorrectVersion = vchVersion == GetParams().Base58Prefix(CChainParams::SECRET_KEY);
313313
return fExpectedFormat && fCorrectVersion;
314314
}
315315

src/base58.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ template<typename K, int Size, CChainParams::Base58Type Type> class CRavenExtKey
139139
void SetKey(const K &key) {
140140
unsigned char vch[Size];
141141
key.Encode(vch);
142-
SetData(Params().Base58Prefix(Type), vch, vch+Size);
142+
SetData(GetParams().Base58Prefix(Type), vch, vch + Size);
143143
}
144144

145145
K GetKey() {
@@ -156,7 +156,7 @@ template<typename K, int Size, CChainParams::Base58Type Type> class CRavenExtKey
156156
}
157157

158158
CRavenExtKeyBase(const std::string& strBase58c) {
159-
SetString(strBase58c.c_str(), Params().Base58Prefix(Type).size());
159+
SetString(strBase58c.c_str(), GetParams().Base58Prefix(Type).size());
160160
}
161161

162162
CRavenExtKeyBase() {}

src/blockencodings.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ ReadStatus PartiallyDownloadedBlock::FillBlock(CBlock& block, const std::vector<
198198
return READ_STATUS_INVALID;
199199

200200
CValidationState state;
201-
if (!CheckBlock(block, state, Params().GetConsensus())) {
201+
if (!CheckBlock(block, state, GetParams().GetConsensus())) {
202202
// TODO: We really want to just check merkle tree manually here,
203203
// but that is expensive, and CheckBlock caches a block's
204204
// "checked-status" (in the CBlock?). CBlock should be able to

src/chain.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ arith_uint256 GetBlockProof(const CBlockIndex& block)
133133
return (~bnTarget / (bnTarget + 1)) + 1;
134134
}
135135

136-
int64_t GetBlockProofEquivalentTime(const CBlockIndex& to, const CBlockIndex& from, const CBlockIndex& tip, const Consensus::ConsensusParams& params)
136+
int64_t GetBlockProofEquivalentTime(const CBlockIndex& to, const CBlockIndex& from, const CBlockIndex& tip, const Consensus::Params& params)
137137
{
138138
arith_uint256 r;
139139
int sign = 1;

src/chain.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ class CBlockIndex
363363

364364
arith_uint256 GetBlockProof(const CBlockIndex& block);
365365
/** Return the time it would take to redo the work difference between from and to, assuming the current hashrate corresponds to the difficulty at tip, in seconds. */
366-
int64_t GetBlockProofEquivalentTime(const CBlockIndex& to, const CBlockIndex& from, const CBlockIndex& tip, const Consensus::ConsensusParams&);
366+
int64_t GetBlockProofEquivalentTime(const CBlockIndex& to, const CBlockIndex& from, const CBlockIndex& tip, const Consensus::Params&);
367367
/** Find the forking point between two chain tips. */
368368
const CBlockIndex* LastCommonAncestor(const CBlockIndex* pa, const CBlockIndex* pb);
369369

src/chainparams.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
#include "arith_uint256.h"
1414

1515
#include <assert.h>
16-
1716
#include "chainparamsseeds.h"
1817

1918
//TODO: Take these out
@@ -248,6 +247,7 @@ class CMainParams : public CChainParams {
248247

249248
// DGW Activation
250249
nDGWActivationBlock = 338778;
250+
//! If you change this value, you must update the value in primitives/block.cpp
251251
nX16RV2ActivationTime = 1569945600; //Tue Oct 01 2019 16:00:00 UTC
252252

253253
nMaxReorganizationDepth = 60; // 60 at 1 minute block timespan is +/- 60 minutes.
@@ -450,15 +450,16 @@ class CTestNetParams : public CChainParams {
450450

451451
// DGW Activation
452452
nDGWActivationBlock = 200;
453-
nX16RV2ActivationTime = 1569931200;
453+
//! If you change this value, you must update the value in primitives/block.cpp
454+
nX16RV2ActivationTime = 1567533600; // Tuesday, September 3, 2019 18:00:00 UTC
454455

455456
nMaxReorganizationDepth = 60; // 60 at 1 minute block timespan is +/- 60 minutes.
456457
nMinReorganizationPeers = 4;
457458
nMinReorganizationAge = 60 * 60 * 12; // 12 hours
458459

459460
nAssetActivationHeight = 6048; // Asset activated block height
460461
nMessagingActivationBlock = 249984; // Messaging activated block height
461-
nRestrictedActivationBlock = 0; // Restricted activated block height // TODO after restricted goes active on testnet
462+
nRestrictedActivationBlock = 308448; // Restricted activated block height // TODO after restricted goes active on testnet
462463
/** RVN End **/
463464

464465
}
@@ -640,6 +641,7 @@ class CRegTestParams : public CChainParams {
640641

641642
// DGW Activation
642643
nDGWActivationBlock = 200;
644+
//! If you change this value, you must update the value in primitives/block.cpp
643645
nX16RV2ActivationTime = 1566571889;
644646

645647
nMaxReorganizationDepth = 60; // 60 at 1 minute block timespan is +/- 60 minutes.
@@ -655,7 +657,7 @@ class CRegTestParams : public CChainParams {
655657

656658
static std::unique_ptr<CChainParams> globalChainParams;
657659

658-
const CChainParams &Params() {
660+
const CChainParams &GetParams() {
659661
assert(globalChainParams);
660662
return *globalChainParams;
661663
}
@@ -671,9 +673,12 @@ std::unique_ptr<CChainParams> CreateChainParams(const std::string& chain)
671673
throw std::runtime_error(strprintf("%s: Unknown chain %s.", __func__, chain));
672674
}
673675

674-
void SelectParams(const std::string& network)
676+
void SelectParams(const std::string& network, bool fForceBlockNetwork)
675677
{
676678
SelectBaseParams(network);
679+
if (fForceBlockNetwork) {
680+
bNetwork.SetNetwork(network);
681+
}
677682
globalChainParams = CreateChainParams(network);
678683
}
679684

0 commit comments

Comments
 (0)