Skip to content

Commit

Permalink
Add testnet options
Browse files Browse the repository at this point in the history
  • Loading branch information
punk8 committed Apr 21, 2021
1 parent a0a839a commit 0f972c9
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ include_directories(RandomX_MinerXDagCore/dar)
include_directories(RandomX_MinerXDagCore/dfstools)

add_executable(DaggerRandomxMiner
RandomX_Miner/Core/global.h
RandomX_Miner/Core/global.cpp
RandomX_Miner/Core/Common.h
RandomX_Miner/Core/CommonData.cpp
RandomX_Miner/Core/CommonData.h
Expand Down
6 changes: 6 additions & 0 deletions RandomX_Miner/Core/MinerManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "Utils/CpuInfo.h"
#include "Utils/Random.h"
#include "Utils/Utils.h"
#include "Core/global.h"

#define WORKER_NAME_MAX_LENGTH 28

Expand Down Expand Up @@ -195,6 +196,10 @@ bool MinerManager::InterpretOption(int& i, int argc, char** argv)
BOOST_THROW_EXCEPTION(BadArgument());
}
}
else if((arg == "-T"))
{
g_net_type = 0;
}
/*else if((arg == "-d") && i + 1 < argc)
{
try
Expand Down Expand Up @@ -315,6 +320,7 @@ void MinerManager::StreamHelp(ostream& _out)
<< " -list-devices List the detected devices and exit. Should be combined with -G or -cpu flag." << endl
//<< " -nvidia-fix <n> Use workaround on high cpu usage with nvidia cards. n - optional value of thread sleep time, should be 0-95. (default: 90)" << endl
<< " -w, -worker Allows to set a worker name." << endl
<< " -T For testnet." << endl
<< endl
/* << " OpenCL configuration:" << endl
<< " -cl-local-work Set the OpenCL local work size. Default is " << CLMiner::_defaultLocalWorkSize << endl
Expand Down
3 changes: 3 additions & 0 deletions RandomX_Miner/Core/global.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#include "global.h"

int g_net_type = 1;
6 changes: 6 additions & 0 deletions RandomX_Miner/Core/global.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#ifndef GLOBAL_H
#define GLOBAL_H
/* the network type */
extern int g_net_type; //1 is mainnet, 0 is testnet

#endif
7 changes: 6 additions & 1 deletion RandomX_Miner/XDagCore/XBlock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,16 @@

#include "XBlock.h"
#include "XTime.h"
#include "Core/global.h"

void XBlock::GenerateFakeBlock(xdag_block *block)
{
memset(block, 0, sizeof(struct xdag_block));
block->field[0].type = (int)xdag_field_type::XDAG_FIELD_HEAD | (uint64_t)((int)xdag_field_type::XDAG_FIELD_SIGN_OUT * 0x11) << 4;
if (g_net_type == 1) {
block->field[0].type = (int)xdag_field_type::XDAG_FIELD_HEAD | (uint64_t)((int)xdag_field_type::XDAG_FIELD_SIGN_OUT * 0x11) << 4;
} else {
block->field[0].type = (int)xdag_field_type::XDAG_FIELD_HEAD_TEST | (uint64_t)((int)xdag_field_type::XDAG_FIELD_SIGN_OUT * 0x11) << 4;
}
block->field[0].time = get_timestamp();
block->field[0].amount = 0;
block->field[0].transport_header = 1;
Expand Down
1 change: 1 addition & 0 deletions RandomX_Miner/XDagCore/XBlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ enum class xdag_field_type
XDAG_FIELD_SIGN_OUT,
XDAG_FIELD_PUBLIC_KEY_0,
XDAG_FIELD_PUBLIC_KEY_1,
XDAG_FIELD_HEAD_TEST,
};

typedef uint64_t xdag_amount_t;
Expand Down

0 comments on commit 0f972c9

Please sign in to comment.