Skip to content

Commit

Permalink
Merged in WGR-178-add-devnet-support (pull request Cryptarchist#6)
Browse files Browse the repository at this point in the history
WGR-178 add devnet support
  • Loading branch information
sean-fixedpointcode committed Nov 22, 2018
2 parents 1ff3dc7 + 5ccb7ee commit cde8ce0
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/bet.cpp
Expand Up @@ -42,7 +42,7 @@ bool IsValidOracleTx(const CTxIn &txin)
CTransaction txPrev;
if (GetTransaction(prevout.hash, txPrev, hashBlock, true)) {

const CTxOut &prevTxOut = txPrev.vout[0];
const CTxOut &prevTxOut = txPrev.vout[prevout.n];
std::string scriptPubKey = prevTxOut.scriptPubKey.ToString();

txnouttype type;
Expand Down
2 changes: 1 addition & 1 deletion src/chainparams.cpp
Expand Up @@ -310,7 +310,7 @@ class CTestNetParams : public CMainParams
/** Bet related parameters **/
strOpCodeProtocolVersion = "1.0"; // Betting OP Code protocol version number (Testnet).
nBetStartHeight = 26150; // The block that betting protocols become active (Testnet).
strOracleWalletAddr = "TCQyQ6dm6GKfpeVvHWHzcRAjtKsJ3hX4AJ"; // Oracle Masternode Event & Result Posting Wallet Address (Testnet).
strOracleWalletAddr = "TEbJasoZZKVFiTB9VGj77JW37Nmakb5C4i"; // Oracle Masternode Event & Result Posting Wallet Address (Testnet).
nBetBlocksIndexTimespan = 23040; // Currently checking back 2 weeks for events and bets for each result. (With approx. 2 days buffer).
strDevPayoutAddr = "TLceyDrdPLBu8DK6UZjKu4vCDUQBGPybcY"; // Development fund payout address (Testnet).
strOMNOPayoutAddr = "TDunmyDASGDjYwhTF3SeDLsnDweyEBpfnP"; // OMNO fund payout address (Testnet).
Expand Down
3 changes: 3 additions & 0 deletions src/init.cpp
Expand Up @@ -538,6 +538,9 @@ std::string HelpMessage(HelpMessageMode mode)
strUsage += HelpMessageOpt("-regtest", _("Enter regression test mode, which uses a special chain in which blocks can be solved instantly.") + " " +
_("This is intended for regression testing tools and app development.") + " " +
_("In this mode -genproclimit controls how many blocks are generated immediately."));
strUsage += HelpMessageOpt("-devnet", _("Enter devnet mode, which is used to bootstrap a development network.") + " " +
_("This makes a node believe that it is downloading its initial blockchain, and that it is fully synced, which allows it to start staking.") + " " +
_("This must be used with -testnet."));
}
strUsage += HelpMessageOpt("-shrinkdebugfile", _("Shrink debug.log file on client startup (default: 1 when no -debug)"));
strUsage += HelpMessageOpt("-testnet", _("Use the test network"));
Expand Down
5 changes: 5 additions & 0 deletions src/main.cpp
Expand Up @@ -1981,6 +1981,11 @@ bool IsInitialBlockDownload()
return false;
bool state = (chainActive.Height() < pindexBestHeader->nHeight - 24 * 6 ||
pindexBestHeader->GetBlockTime() < GetTime() - 6 * 60 * 60); // ~144 blocks behind -> 2 x fork detection time

if (GetBoolArg("-testnet", false) && GetBoolArg("-devnet", false)) {
state = true;
}

if (!state)
lockIBDState = true;
return state;
Expand Down
9 changes: 8 additions & 1 deletion src/masternode-sync.cpp
Expand Up @@ -52,8 +52,12 @@ bool CMasternodeSync::IsBlockchainSynced()
CBlockIndex* pindex = chainActive.Tip();
if (pindex == NULL) return false;

unsigned int offset = 60 * 60;
if (GetBoolArg("-devnet", false)) {
offset *= 48;
}

if (pindex->nTime + 60 * 60 < GetTime())
if (pindex->nTime + offset < GetTime())
return false;

fBlockchainSynced = true;
Expand Down Expand Up @@ -141,6 +145,9 @@ void CMasternodeSync::GetNextAsset()
case (MASTERNODE_SYNC_FAILED): // should never be used here actually, use Reset() instead
ClearFulfilledRequest();
RequestedMasternodeAssets = MASTERNODE_SYNC_SPORKS;
if (GetBoolArg("-devnet", false)) {
RequestedMasternodeAssets = MASTERNODE_SYNC_FINISHED;
}
break;
case (MASTERNODE_SYNC_SPORKS):
RequestedMasternodeAssets = MASTERNODE_SYNC_LIST;
Expand Down
4 changes: 2 additions & 2 deletions src/rpcwallet.cpp
Expand Up @@ -840,7 +840,7 @@ UniValue placebet(const UniValue& params, bool fHelp)
// blockchain incorrectly if its length is less than 5. This behaviour would
// ideally be investigated and corrected/justified when time allows.
std::string opCode;
plBet.ToOpCode(plBet, opCode);
CPeerlessBet::ToOpCode(plBet, opCode);
SendMoney(address.Get(), nAmount, wtx, false, opCode);

return wtx.GetHash().GetHex();
Expand Down Expand Up @@ -890,7 +890,7 @@ UniValue placechaingamesbet(const UniValue& params, bool fHelp)
CChainGamesBet cgBet(eventId);

std::string opCode;
plBet.ToOpCode(cgBet, opCode);
CChainGamesBet::ToOpCode(cgBet, opCode);

// Process transaction
SendMoney(address.Get(), nAmount, wtx, false, opCode);
Expand Down
8 changes: 8 additions & 0 deletions src/wagerrd.cpp
Expand Up @@ -107,6 +107,14 @@ bool AppInit(int argc, char* argv[])
return false;
}

// We require `-devnet` to be used with `-testnet` because using the
// `-devnet` flag when running on mainnet has the potential to get the
// node banned, due to incorrect knowledge about its own synced status.
if (GetBoolArg("-devnet", false) && !GetBoolArg("-testnet", false)) {
fprintf(stderr, "Error: -devnet requires -testnet.\n");
return false;
}

// parse masternode.conf
std::string strErr;
if (!masternodeConfig.read(strErr)) {
Expand Down

0 comments on commit cde8ce0

Please sign in to comment.