Skip to content

Commit

Permalink
sserver: add a new option "single_user_chain", the entire sserver per…
Browse files Browse the repository at this point in the history
…forms chain switching according to one user's selection.
  • Loading branch information
SwimmingTiger committed Mar 22, 2020
1 parent 303a8f8 commit ab55948
Show file tree
Hide file tree
Showing 11 changed files with 689 additions and 15 deletions.
179 changes: 179 additions & 0 deletions docker/btcpool/test/btc/cfg/sserver-single-user.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
#
# stratum server cfg
#
# @since 2016-06
# @copyright btc.com
#

# is using testnet3
testnet = false;

zookeeper = {
brokers = "zookeeper:2181"; # "10.0.0.1:2181,10.0.0.2:2181,..."
};

sserver = {
# serverType
type = "BTC";

ip = "0.0.0.0";
port = 3333;

# should be global unique, range: [1, 255]
# If the id is 0, try to automatically assign one from zookeeper.
id = 1;
# The lock path used when automatically assigning an id
zookeeper_lock_path = "/locks/sserver_mchain";

# how many seconds between two share submit
share_avg_seconds = 10;

# the lifetime of a job
# It should not be too short, otherwise the valid share will be rejected due to job not found.
max_job_lifetime = 300;

# the job interval
# sserver will push latest job if there are no new jobs for this interval
mining_notify_interval = 3;

# default difficulty (hex)
default_difficulty = "1";

# max difficulty (hex)
max_difficulty = "4000000000000000";

# min difficulty (hex)
min_difficulty = "1";

# Adjust difficulty once every N second
diff_adjust_period = 900;

# Override these in each chain (optionally)
nicehash = {
# Set to true if you want to force minimal difficulty for whole sserver
forced = false;

# Fallback value when ZooKeeper is not available
min_difficulty = "10000";

# Read NiceHash minimal difficulty from this ZooKeeper node
min_difficulty_zookeeper_path = "/nicehash/sha256/min_difficulty"
};

#
# version_mask, uint32_t
# 2(0x00000002) : allow client change bit 1
# 16(0x00000010) : allow client change bit 4
# 536862720(0x1fffe000) : allow client change bit 13 to 28
#
# version_mask = 0;
# version_mask = 16;
# version_mask = 536862720; // recommended, BIP9 security
# ...
#
version_mask = 536862720;

# Mining multi chains (such as BTC and BCH) with the same sserver.
# Sserver will query zookeeper to find the chain that a user want mining.
multi_chains = true;

########################## dev options #########################

# if enable simulator, all share will be accepted. for testing
enable_simulator = false;

# if enable it, all share will make block and submit. for testing
enable_submit_invalid_block = false;

# if enable, difficulty sent to miners is always dev_fixed_difficulty. for development
enable_dev_mode = false;

# difficulty to send to miners. for development
dev_fixed_difficulty = 0.005;

###################### end of dev options ######################
};

chains = (
{
name = "btc";
users_list_id_api_url = "http://userlist/userlist-btc.php";
#zookeeper_userid_map = "/sserver/userid/btc/";

# write last mining notify job send time to file, for monitor
file_last_notify_time = "/tmp/sserver_lastnotifytime_btc.txt";

# kafka brokers
kafka_brokers = "kafka:9092"; # "10.0.0.1:9092,10.0.0.2:9092,..."
# kafka topics
job_topic = "BtcJob";
share_topic = "BtcShare";
solved_share_topic = "BtcSolvedShare";
common_events_topic = "BtcCommonEvents";
auxpow_solved_share_topic = "AuxSolvedShare";
rsk_solved_share_topic = "RskSolvedShare";

single_user_puid = 11111;
},
{
name = "bch";
users_list_id_api_url = "http://userlist/userlist-bch.php";
#zookeeper_userid_map = "/sserver/userid/bch/";

# write last mining notify job send time to file, for monitor
file_last_notify_time = "/tmp/sserver_lastnotifytime_bch.txt";

# kafka brokers
kafka_brokers = "kafka:9092"; # "10.0.0.1:9092,10.0.0.2:9092,..."
# kafka topics
job_topic = "BchJob";
share_topic = "BchShare";
solved_share_topic = "BchSolvedShare";
common_events_topic = "BchCommonEvents";
auxpow_solved_share_topic = "AuxSolvedShare";
rsk_solved_share_topic = "RskSolvedShare";

single_user_puid = 22222;
}
);

users = {
# Make the user name case insensitive
case_insensitive = true;

# The parent node of userName-chainName map in Zookeeper
zookeeper_userchain_map = "/sserver/userchain/bitcoin";

# remove the suffix appended to the user name
# example: tiger_eth -> tiger, aaa_bbb_ccc -> aaa_bbb
strip_user_suffix = true;
user_suffix_separator = "_";

# user auto register
enable_auto_reg = false;
auto_reg_max_pending_users = 50;
zookeeper_auto_reg_watch_dir = "/sserver/autoreg";

single_user_chain = true;

# Enable single user mode.
# In this mode, all sub-accounts connected to the sserver will become the worker name prefix for a specified user.
# Example, a worker "user2.11x20" will become "user1.user2.11x20".
single_user_mode = true;
single_user_name = "hu60";

# The interval that checking if a user's chain be switched
# The timing check is just a backup measure to ensure successful chain switching.
# Real-time zookeeper event notification is the main measure.
namechains_check_interval = 5;
};

management = {
enabled = true; # default: true

kafka_brokers = "kafka:9092"; # "10.0.0.1:9092,10.0.0.2:9092,..."
controller_topic = "BtcManController";
processor_topic = "BtcManProcessor";

auto_switch_chain = true;
};
14 changes: 13 additions & 1 deletion docker/btcpool/test/btc/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,19 @@ services:
volumes:
- ./cfg:/work/config
command: /wait-for-it.sh zookeeper:2181 -- /wait-for-it.sh kafka:9092 -- /wait-for-it.sh userlist:80 -- sserver -c /work/config/sserver-mchain.cfg


sserver-single-user:
depends_on:
- zookeeper
- kafka
- userlist
image: btccom/btcpool-${TEST_SUITE}
ports:
- 53337:3333
volumes:
- ./cfg:/work/config
command: /wait-for-it.sh zookeeper:2181 -- /wait-for-it.sh kafka:9092 -- /wait-for-it.sh userlist:80 -- sserver -c /work/config/sserver-single-user.cfg

blkmaker:
depends_on:
- kafka
Expand Down
Loading

0 comments on commit ab55948

Please sign in to comment.