Summary of core mechanisms
- Simultaneous monitoring of KAFKA KAFKA_TOPIC_RAWGBT and Kafka_topic_nmc_auxblock to support mixed mining
- GBT messages received if the delay exceeds 60 seconds with local time will be discarded if the delay exceeds 3 seconds will print log
- The available GBT messages will be gbttime+isemptyblock+height to construct the key to write to the local map, and the Gbthash will write to the local queue
- Local Gbthash queues save only the last 20, local gbtmap GBT message validity: Non-empty GBT valid for 90 seconds, empty GBT valid for 15 seconds, expiration clears
?? * Validity period can be specified from the configuration file
- GBT message if the height is lower than the local GBT height, and the local GBT is not empty, and not more than twice times the local time interval STRATUMJOBINTERVAL_,GBT message will be discarded
- In three cases, the stratumjob will be sent to Kafka immediately:
?? height greater than local height (that is, new blocks found)
?? The height is the same as the local height, but the previous job is an empty block job, but the new GBT non-empty block
?? * Reach the scheduled time interval of 20 seconds (can be specified from the configuration file)
The Jobmaker command uses
Jobmaker, used for monitoring Kafka get the latest Bitcoin GBT messages, as well as the domain name currency nmcauxblock messages, and then send them to stratumjob by constructing Kafka.
jobmaker -c jobmaker.cfg -l log_dir#-c指定jobmaker配置文件#-l指定日志目录
Jobmaker.cfg configuration file
//是否使用testnettestnet = true;jobmaker = {//发送stratum job间隔秒数stratum_job_interval = 20;//gbt生命周期秒数gbt_life_time = 90;//空gbt(即不含交易)生命周期秒数//此值应>=10empty_gbt_life_time = 15;//最近一次stratum job发送时间写入文件file_last_job_time = "/work/xxx/jobmaker_lastjobtime.txt";//区块版本,默认为0表示使用bitcoind返回的区块版本block_version = 0;};//kafka集群kafka = {brokers = "1.1.1.1:9092,2.2.2.2:9092,3.3.3.3:9092";};//zookeeper集群zookeeper = {brokers = "1.1.1.1:2181,2.2.2.2:2181,3.3.3.3:2181";};pool = {//支付地址payout_address = "my2dxGb5jz43ktwGxg2doUaEb9WhZ9PQ7K";//coinbase infocoinbase_info = "region1/Project BTCPool/";};
A separate STRATUMJOB data structure definition is attached:
"' C + +
Class Stratumjob {
Public
Jobid:timestamp + Gbthash, for the purpose of ensuring non-repetition
UInt64T jobId;
Gbthash
String Gbthash;
Previous Chunk Hash
uint256 Prevhash;
Previous chunk hash (small byte order)
String prevhashbestr_;
Block height
Int32t height;
Coinbase Trading
String Coinbase1;
String Coinbase2;
Merkle Branches
Vector<uint256> Merklebranch_;
Block version
Int32t nversion;
Difficulty target
UInt32T nBits;
Time stamp
UInt32T ntime;
Minimum effective time
UInt32T Mintime;
Mining incentives
Int64T Coinbasevalue;
Witness commitment (if quarantine witness is not enabled, empty here)
String Witnesscommitment;
Nbits to target difficulty target
uint256 Networktarget;
Domain Coin Mixed Mining
UInt32T nmcauxbits;
uint256 Nmcauxblockhash;
uint256 Nmcnetworktarget;
Int32t nmcheight;
String Nmcrpcaddr;
String Nmcrpcuserpass;
Method definition Slightly
};
Brother Lian Blockchain tutorial Btcpool mining pool Source Code Analysis Jobmaker Module parsing