Skip to content

Commit

Permalink
redundent redis stats (replaced)
Browse files Browse the repository at this point in the history
  • Loading branch information
avaziman committed Dec 24, 2022
1 parent 6769905 commit a65fd88
Show file tree
Hide file tree
Showing 23 changed files with 139 additions and 371 deletions.
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ execute_process(
set (CMAKE_BUILD_TYPE "Debug")

if(CMAKE_BUILD_TYPE STREQUAL "Release")
# Makes the executable run the fastest on host cpu and enable optimizations
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native -O3")
# set(CMAKE_EXE_LINKER_FLAGS "-static")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2 -static-libstdc++")
else()
# -g3 maximum debugging information
# link time optimization
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -flto -O0 -g3 -DDEBUG=1-Wsubobject-linkage -Wmissing-template-keyword")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -flto -O0 -g3 -DDEBUG=1-Wsubobject-linkage -Wmissing-template-keyword -DSTATIC_CONCPP=1")
add_compile_definitions(SIMDJSON_DEVELOPMENT_CHECKS)
endif()

Expand Down
37 changes: 22 additions & 15 deletions config/coins/ZANO.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,44 @@
"control_port": 1111,
"stratum_port": 4444,
"redis": {
"redis_port": 6379,
"hashrate_ttl": 86400
"host": "127.0.0.1:6379",
"db_index": 0,
"hashrate_ttl_seconds": 86400
},
"mysql": {
"host": "127.0.0.1:3306",
"user": "root",
"pass": "password",
"db_name": "ZANO"
},
"stats": {
"effort_interval_seconds": 10,
"hashrate_interval_seconds": 5,
"hashrate_interval_seconds1": 10,
"average_hashrate_interval_seconds": 5,
"mined_blocks_interval": 600,
"diff_adjust_seconds": 30000
"hashrate_interval_seconds": 300,
"average_hashrate_interval_seconds": 21600,
"mined_blocks_interval": 86400,
"diff_adjust_seconds": 300
},
"pow_fee": 0.01,
"pow_fee": 0.0075,
"pos_fee": 0.01,
"default_difficulty": 20000000.0,
"minimum_difficulty": 0.000001,
"default_difficulty": 5000000.0,
"minimum_difficulty": 10000,
"target_shares_rate": 100.0,
"pool_addr": "ZxBvJDuQjMG9R2j4WnYUhBYNrwZPwuyXrC7FHdVmWqaESgowDvgfWtiXeNGu8Px9B24pkmjsA39fzSSiEQG1ekB225ZnrMTBp",
"redis_host": "127.0.0.1:6379",
"socket_recv_timeout_seconds": 3,
"block_poll_interval": 1,
"block_poll_interval": 10,
"payment_interval_seconds": 5,
"min_payout_threshold": 10000000000000,
"rpcs": [
{
"host": "127.0.0.1:12111",
"auth": "iZ2bZfXdeN626rkyy9YsnfeT1Qq1K6XamE4brWm3tzP5hDUAig4dHmKSqe4yyq5dgbSPjmpLbfidqPyDXAuFY2J9544F95vagSF1Xqq3eCUp=="
"host": "127.0.0.1:11211",
"auth": ""
}
],
"payment_rpcs": [
{
"host": "127.0.0.1:12111",
"auth": "iZ2bZfXdeN626rkyy9YsnfeT1Qq1K6XamE4brWm3tzP5hDUAig4dHmKSqe4yyq5dgbSPjmpLbfidqPyDXAuFY2J9544F95vagSF1Xqq3eCUp=="
"host": "127.0.0.1:12233",
"auth": ""
}
]
}
4 changes: 2 additions & 2 deletions config/coins/ZANOTEST.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
"redis": {
"host": "127.0.0.1:6379",
"db_index": 0,
"hashrate_ttl": 25
"hashrate_ttl_seconds": 25
},
"mysql": {
"host": "127.0.0.1:3306",
"user": "root",
"pass": "password",
"db_name": "test"
"db_name": "ZANO"
},
"stats": {
"effort_interval_seconds": 10,
Expand Down
10 changes: 5 additions & 5 deletions scripts/setup/procedures.sql
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
CREATE TABLE addresses (
id INT UNSIGNED UNIQUE AUTO_INCREMENT,
address char(255) NOT NULL UNIQUE,
address_md5 char(32) NOT NULL,
alias char(255) UNIQUE
);

Expand Down Expand Up @@ -60,7 +61,7 @@ CREATE TABLE payouts (

CREATE TABLE payout_entries (
payout_id INT UNSIGNED NOT NULL,
miner_id INT UNSIGNED NOT NULL,''
miner_id INT UNSIGNED NOT NULL,
amount BIGINT UNSIGNED NOT NULL,

FOREIGN KEY (payout_id) REFERENCES payouts(id),
Expand Down Expand Up @@ -150,9 +151,9 @@ CREATE PROCEDURE AddMiner(
IN join_time BIGINT UNSIGNED
) BEGIN
INSERT INTO
addresses (address, alias)
addresses (address, address_md5, alias)
VALUES
(address, alias);
(address, MD5(address), alias);

SET
@id = LAST_INSERT_ID();
Expand Down Expand Up @@ -199,15 +200,14 @@ DELIMITER ;

DELIMITER //
CREATE PROCEDURE AddWorker(
IN minerid INT UNSIG,
IN minerid INT UNSIGNED,
IN wname CHAR(255),
IN join_time BIGINT UNSIGNED
) BEGIN
INSERT INTO
workers (miner_id, name, join_time)
VALUES
(minerid, wname, join_time);

END//
DELIMITER ;

Expand Down
80 changes: 0 additions & 80 deletions scripts/setup/redis_scripts.lua

This file was deleted.

37 changes: 23 additions & 14 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,20 @@ FetchContent_Declare(
GIT_SHALLOW TRUE)
FetchContent_MakeAvailable(fmt)

FetchContent_Declare(
hiredis
GIT_REPOSITORY https://github.com/redis/hiredis.git
GIT_TAG tags/v1.1.0
GIT_SHALLOW TRUE)
FetchContent_MakeAvailable(hiredis)

FetchContent_Declare(
mysqlcppconn
GIT_REPOSITORY https://github.com/mysql/mysql-connector-cpp.git
GIT_TAG tags/8.0.31
GIT_SHALLOW TRUE)
FetchContent_GetProperties(mysqlcppconn)

# optimized hash function
add_subdirectory(crypto/cn)
add_subdirectory(crypto/verushash)
Expand Down Expand Up @@ -50,35 +64,30 @@ file(GLOB SRC_FILES
# BOOST
FIND_PACKAGE(Boost 1.40 COMPONENTS program_options REQUIRED)

include(FindPkgConfig)

add_library(${PROJECT_NAME_CORE} ${SRC_FILES})
add_library(${PROJECT_NAME_CORE} STATIC ${SRC_FILES})

set(SICKPOOL_INCLUDE PUBLIC . PUBLIC stats PUBLIC crypto PUBLIC daemon PUBLIC stratum
PUBLIC static_config PUBLIC blocks PUBLIC round
PUBLIC persistence/redis PUBLIC persistence/mysql PUBLIC persistence
PUBLIC payments PUBLIC logger PUBLIC shares PUBLIC jobs PUBLIC difficulty PUBLIC control)
target_include_directories(${PROJECT_NAME_CORE} PUBLIC ${SICKPOOL_INCLUDE})

find_path(HIREDIS_HEADER hiredis)
find_library(HIREDIS_LIB hiredis)

target_include_directories(${PROJECT_NAME_CORE} PUBLIC ${HIREDIS_HEADER})
# find_path(HIREDIS_HEADER hiredis)
# find_library(HIREDIS_LIB hiredis)
target_include_directories(${PROJECT_NAME_CORE} PUBLIC ${HIREDIS_HEADER} ${mysqlcppconn_SOURCE_DIR}/include)

target_link_libraries(
${PROJECT_NAME_CORE}
${Boost_LIBRARIES}
${HIREDIS_LIB}

# ${HIREDIS_LIB}
hiredis_static
mysqlcppconn
# mysqlcppconn-static
pthread
cryptonote_utils
simdjson
fmt::fmt
sickverushash

# sickx25x
)

# add_subdirectory(blocks)
# add_subdirectory(daemon)
# add_subdirectory(payments)
)
1 change: 1 addition & 0 deletions src/blocks/block_watcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ void BlockWatcher<confs>::CheckImmatureSubmissions()
: EnumName<BlockStatus::ORPHANED>());

it = immature_block_submissions.erase(it);

}
else
{
Expand Down
2 changes: 1 addition & 1 deletion src/config_parser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ void ParseCoinConfig(const simdjson::padded_string& json, CoinConfig& cnfg,

AssignJson("host", cnfg.redis.host, ob, logger);
AssignJson("db_index", cnfg.redis.db_index, ob, logger);
AssignJson("hashrate_ttl", cnfg.redis.hashrate_ttl_seconds, ob, logger);
AssignJson("hashrate_ttl_seconds", cnfg.redis.hashrate_ttl_seconds, ob, logger);

ob = configDoc["mysql"].get_object();
AssignJson("host", cnfg.mysql.host, ob, logger);
Expand Down
6 changes: 3 additions & 3 deletions src/payments/payment_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,19 +70,19 @@ bool PaymentManager::GetRewardsPROP(round_shares_t& miner_shares,
}
miner_shares.reserve(miner_efforts.size());

for (auto& [addr, effort] : miner_efforts)
for (auto& [miner_id, effort] : miner_efforts)
{
RoundReward round_share;
round_share.effort = effort;
round_share.share = round_share.effort / total_effort;
round_share.reward = static_cast<int64_t>(
round_share.share * static_cast<double>(substracted_reward));
miner_shares.try_emplace(addr.id, round_share);
miner_shares.try_emplace(miner_id, round_share);

logger.Log<LogType::Info>(
"Miner round share: {}, effort: {}, share: {}, reward: "
"{}, total effort: {}",
addr.GetHex(), round_share.effort, round_share.share,
miner_id, round_share.effort, round_share.share,
round_share.reward, total_effort);
}

Expand Down
3 changes: 1 addition & 2 deletions src/persistence/mysql/mysql_manager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@
#include "block_submission.hpp"
#include "coin_config.hpp"
#include "redis_interop.hpp"
#include "redis_manager.hpp"
#include "round_share.hpp"
#include "stats.hpp"
#include "utils/hex_utils.hpp"
#include "redis_manager.hpp"
#include "round_share.hpp"

#define PRINT_MYSQL_ERR(e) \
logger.Log<LogType::Critical>("Failed to mysql: {}", e.what())
Expand Down
1 change: 0 additions & 1 deletion src/persistence/redis/key_names.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ struct KeyNames
const std::string hashrate_pool_compact =
Format({hashrate_pool, EnumName<COMPACT>()});

const std::string miner_worker_count = Format({coin, EnumName<SOLVER>(), EnumName<WORKER>(), EnumName<COUNT>()});
const std::string worker_count = Format({coin, EnumName<WORKER_COUNT>()});
const std::string worker_count_pool =
Format({worker_count, EnumName<POOL>()});
Expand Down
Loading

0 comments on commit a65fd88

Please sign in to comment.