Skip to content

Commit

Permalink
configuration shoud be finished
Browse files Browse the repository at this point in the history
  • Loading branch information
loldlm1 committed Aug 2, 2017
1 parent 635e281 commit 7cf45a9
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 67 deletions.
2 changes: 1 addition & 1 deletion src/CryptoNoteConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ namespace CryptoNote {
const char CRYPTONOTE_POOLDATA_FILENAME[] = "poolstate.bin";
const char P2P_NET_DATA_FILENAME[] = "p2pstate.bin";
const char MINER_CONFIG_FILE_NAME[] = "miner_conf.json";
const char GENESIS_COINBASE_TX_HEX[] = "";
const char GENESIS_COINBASE_TX_HEX[] = "010a01ff0001f0e6fedd8d58029b2e4c0281c0b02e7c53291a94d1d0cbff8883f8024f5142ee494ffbbd088071210157ad05b4c3ad7adcd2a46acea01bbff85be0aa67eab39231828fd560bb74b9a0";
} // parameters

const char CRYPTONOTE_NAME[] = "chavezcoin";
Expand Down
14 changes: 7 additions & 7 deletions src/CryptoNoteCore/Currency.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,13 @@ class Currency {
size_t difficultyLagV2() const { return m_difficultyLagV2; }
size_t difficultyCutV1() const { return m_difficultyCutV1; }
size_t difficultyCutV2() const { return m_difficultyCutV2; }
size_t difficultyWindowByBlockVersion(uint8_t blockMajorVersion) const;
size_t difficultyWindowByBlockVersion(uint8_t blockMajorVersion) const;
size_t difficultyLag() const { return m_difficultyLag; }
size_t difficultyLagByBlockVersion(uint8_t blockMajorVersion) const;
size_t difficultyLagByBlockVersion(uint8_t blockMajorVersion) const;
size_t difficultyCut() const { return m_difficultyCut; }
size_t difficultyCutByBlockVersion(uint8_t blockMajorVersion) const;
size_t difficultyCutByBlockVersion(uint8_t blockMajorVersion) const;
size_t difficultyBlocksCount() const { return m_difficultyWindow + m_difficultyLag; }
size_t difficultyBlocksCountByBlockVersion(uint8_t blockMajorVersion) const;
size_t difficultyBlocksCountByBlockVersion(uint8_t blockMajorVersion) const;

size_t maxBlockSizeInitial() const { return m_maxBlockSizeInitial; }
uint64_t maxBlockSizeGrowthSpeedNumerator() const { return m_maxBlockSizeGrowthSpeedNumerator; }
Expand Down Expand Up @@ -120,11 +120,11 @@ size_t difficultyBlocksCountByBlockVersion(uint8_t blockMajorVersion) const;
const Crypto::Hash& genesisBlockHash() const { return cachedGenesisBlock->getBlockHash(); }

bool getBlockReward(uint8_t blockMajorVersion, size_t medianSize, size_t currentBlockSize, uint64_t alreadyGeneratedCoins, uint64_t fee,
uint64_t& reward, int64_t& emissionChange) const;
uint64_t& reward, int64_t& emissionChange) const;
size_t maxBlockCumulativeSize(uint64_t height) const;

bool constructMinerTx(uint8_t blockMajorVersion, uint32_t height, size_t medianSize, uint64_t alreadyGeneratedCoins, size_t currentBlockSize,
uint64_t fee, const AccountPublicAddress& minerAddress, Transaction& tx, const BinaryArray& extraNonce = BinaryArray(), size_t maxOuts = 1) const;
uint64_t fee, const AccountPublicAddress& minerAddress, Transaction& tx, const BinaryArray& extraNonce = BinaryArray(), size_t maxOuts = 1) const;

bool isFusionTransaction(const Transaction& transaction) const;
bool isFusionTransaction(const Transaction& transaction, size_t size) const;
Expand All @@ -141,7 +141,7 @@ size_t difficultyBlocksCountByBlockVersion(uint8_t blockMajorVersion) const;
bool parseAmount(const std::string& str, uint64_t& amount) const;

Difficulty nextDifficulty(std::vector<uint64_t> timestamps, std::vector<Difficulty> cumulativeDifficulties) const;
Difficulty nextDifficulty(uint8_t version, std::vector<uint64_t> timestamps, std::vector<Difficulty> cumulativeDifficulties) const;
Difficulty nextDifficulty(uint8_t version, std::vector<uint64_t> timestamps, std::vector<Difficulty> cumulativeDifficulties) const;

bool checkProofOfWorkV1(Crypto::cn_context& context, const CachedBlock& block, Difficulty currentDifficulty) const;
bool checkProofOfWorkV2(Crypto::cn_context& context, const CachedBlock& block, Difficulty currentDifficulty) const;
Expand Down
74 changes: 15 additions & 59 deletions src/Daemon/Daemon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,29 +76,13 @@ namespace

bool command_line_preprocessor(const boost::program_options::variables_map& vm, LoggerRef& logger);
void print_genesis_tx_hex(const po::variables_map& vm, LoggerManager& logManager) {
std::vector<CryptoNote::AccountPublicAddress> targets;
auto genesis_block_reward_addresses = command_line::get_arg(vm, arg_genesis_block_reward_address);

CryptoNote::CurrencyBuilder currencyBuilder(logManager);
CryptoNote::Currency currency = currencyBuilder.currency();
CryptoNote::Transaction tx = CryptoNote::CurrencyBuilder(logManager).generateGenesisTransaction();
CryptoNote::BinaryArray txb = CryptoNote::toBinaryArray(tx);
std::string tx_hex = Common::toHex(txb);

for (const auto& address_string : genesis_block_reward_addresses) {
CryptoNote::AccountPublicAddress address;
if (!currency.parseAccountAddressString(address_string, address)) {
std::cout << "Failed to parse address: " << address_string << std::endl;
return;
}
targets.emplace_back(std::move(address));
}

if (CryptoNote::parameters::GENESIS_BLOCK_REWARD > 0) {
std::cout << "Error: genesis block reward addresses are not defined" << std::endl;
} else {
CryptoNote::Transaction tx = currencyBuilder.generateGenesisTransaction();
std::string tx_hex = Common::toHex(CryptoNote::toBinaryArray(tx));
std::cout << "Add this line into your coin configuration file as is: " << std::endl;
std::cout << "GENESIS_COINBASE_TX_HEX=" << tx_hex << std::endl;
}
std::cout << "Insert this line into your coin configuration file as is: " << std::endl;
std::cout << "const char GENESIS_COINBASE_TX_HEX[] = \"" << tx_hex << "\";" << std::endl;

return;
}
Expand Down Expand Up @@ -181,24 +165,14 @@ int main(int argc, char* argv[])
config_path = data_dir_path / config_path;
}

// boost::system::error_code ec;
// if (boost::filesystem::exists(config_path, ec)) {
// std::cout << "Success: Configuration file openned: " << config_path << std::endl;
// po::store(po::parse_config_file<char>(config_path.string<std::string>().c_str(), desc_cmd_sett, true), vm);
// }
// else
// {
// std::cout << "Configuration error: Cannot open configuration file" << std::endl;
// std::cout << "" << std::endl;
// std::cout << "Usage:" << std::endl;
// std::cout << "Windows: forknoted.exe --config-file configs/dashcoin.conf" << std::endl;
// std::cout << "Linux/Mac: ./forknoted --config-file configs/dashcoin.conf" << std::endl;
// return false;
// }
boost::system::error_code ec;
if (boost::filesystem::exists(config_path, ec)) {
po::store(po::parse_config_file<char>(config_path.string<std::string>().c_str(), desc_cmd_sett), vm);
}

po::notify(vm);
if (command_line::get_arg(vm, command_line::arg_data_dir) == Tools::getDefaultDataDirectory() && command_line::has_arg(vm, arg_CRYPTONOTE_NAME) && !command_line::get_arg(vm, arg_CRYPTONOTE_NAME).empty()) {
boost::replace_all(data_dir, CryptoNote::CRYPTONOTE_NAME, command_line::get_arg(vm, arg_CRYPTONOTE_NAME));
if (command_line::get_arg(vm, command_line::arg_data_dir) == Tools::getDefaultDataDirectory()) {
boost::replace_all(data_dir, CryptoNote::CRYPTONOTE_NAME, CryptoNote::CRYPTONOTE_NAME);
}
data_dir_path = data_dir;
if (command_line::get_arg(vm, arg_print_genesis_tx)) {
Expand Down Expand Up @@ -242,38 +216,20 @@ int main(int argc, char* argv[])

//create objects and link them
CryptoNote::CurrencyBuilder currencyBuilder(logManager);
currencyBuilder.testnet(testnet_mode);

try {
currencyBuilder.currency();
} catch (std::exception&) {
std::cout << "GENESIS_COINBASE_TX_HEX constant has an incorrect value. Please launch: " << CryptoNote::CRYPTONOTE_NAME << "d --" << arg_print_genesis_tx.name;
return 1;
}

CryptoNote::Currency currency = currencyBuilder.currency();

CryptoNote::Checkpoints checkpoints(logManager);
std::vector<CryptoNote::CheckpointData> checkpoint_input;
std::vector<std::string> checkpoint_args = command_line::get_arg(vm, arg_CHECKPOINT);
std::vector<std::string> checkpoint_blockIds;

if (command_line::has_arg(vm, arg_CHECKPOINT) && checkpoint_args.size() != 0)
{
for(const std::string& str: checkpoint_args) {
std::string::size_type p = str.find(':');
if(p != std::string::npos)
{
uint32_t checkpoint_height = std::stoull(str.substr(0, p));
checkpoint_blockIds.push_back(str.substr(p+1, str.size()));
checkpoint_input.push_back({ checkpoint_height, checkpoint_blockIds.back().c_str() });
}
}
}
else
{
if (command_line::get_arg(vm, arg_CRYPTONOTE_NAME) == "bytecoin") {
checkpoint_input = CryptoNote::CHECKPOINTS;
}
}
std::vector<CryptoNote::CheckpointData> checkpoint_input;
checkpoint_input = CryptoNote::CHECKPOINTS;

if (!testnet_mode) {
for (const auto& cp : checkpoint_input) {
Expand Down

0 comments on commit 7cf45a9

Please sign in to comment.