Summary of core mechanism of-blockmaker module analysis in Btcpool mine pool
- Blkmaker can connect multiple bitcoind nodes
- Blkmaker Listen and receive 4 types of messages: RAWGBT, Stratum_job, Solved_share, and Nmc_solved_share
- Listener RAWGBT Purpose to get a list of gbthash/transactions for building Block,gbthash and Vtxs write RAWGBTMAP_
?? * RAWGBTMAP_ Save the last 100 Gbthash/vtxs
- Listenfor stratum job purpose to get jobId/gbthash,jobid and Gbthash write Jobid2gbthash
?? * Jobid2gbthash Save the last 120 Jobid/gbthash
- Monitoring Solved_share purpose for obtaining blockheader and Coinbasetx
?? * BLOCKHEADER+COINBASETX+VTXS Construction Block
- The constructed block commits all bitcoind nodes that are connected
- Constructed block warehousing, inbound fields include:
?? Puid, worker_id, Worker_full_name, job_id, height, hash
?? Rewards (i.e. Coinbasevalue), size (i.e. blksize), Prev_hash, Bits, version, Created_at
?? * Created_at for storage time non-burst block time
The Blockmaker command uses
Blockmaker is used for monitoring Kafka to obtain new Bitcoin chunks and domain name coins, while listening Kafka get GBT messages and job messages to construct a list of transactions, and finally assemble complete chunks to be submitted to the Bitcoin node.
blkmaker -c blkmaker.cfg -l log_dir#-c指定blkmaker配置文件#-l指定日志目录
Blkmaker.cfg configuration file
//比特币节点bitcoinds = ({rpc_addr = ""; //rpc地址rpc_userpwd = ""; //rpc权限,格式如username:password});//kafka集群kafka = {brokers = "1.1.1.1:9092,2.2.2.2:9092,3.3.3.3:9092";};//mysql配置,用于存储已发现的块pooldb = {host = "";port = 3306;username = "dbusername";password = "dbpassword";dbname = "";};
FOUND_BLOCKS database structure-MySQL dump 10.13? Distrib 5.7.20, for Linux (x86_64)
--host:172.17.228.162?? database:bpool_local_db
--Server version 5.7.18-16-log
/!40101 SET @[email protected] @CHARACTER_SET_CLIENT /;
/!40101 SET @[email protected] @CHARACTER_SET_RESULTS /;
/!40101 SET @[email protected] @COLLATION_CONNECTION /;
/!40101 SET NAMES UTF8 /;
/!40103 SET @[email protected] @TIME_ZONE /;
/!40103 SET time_zone= ' +00:00 ' /;
/!40014 SET @[email protected] @UNIQUE_CHECKS, unique_checks=0 /;
/!40014 SET @[email protected] @FOREIGN_KEY_CHECKS, foreign_key_checks=0 /;
/!40101 SET @[email protected] @SQL_MODE, sql_mode= ' No_auto_value_on_zero ' /;
/!40111 SET @[email protected] @SQL_NOTES, sql_notes=0 /;
--
--Table structure for table
found_blocks
DROP TABLE IF EXISTSfound_blocks
;
/!40101 SET @saved_cs_client??? = @ @character_set_client/;
/!40101 SET character_set_client = UTF8/;
CREATE TABLEfound_blocks
(
?id
Int (one) not NULL auto_increment,
?puid
Int (one) is not NULL,
?worker_id
BigInt () not NULL,
?worker_full_name
varchar (not NULL),
?job_id
bigint (unsigned) not NULL,
?height
Int (one) is not NULL,
?is_orphaned
tinyint (4) not NULL DEFAULT ' 0 ',
?hash
char (+) is not NULL,
?rewards
BigInt () not NULL,
?size
Int (one) is not NULL,
?prev_hash
char (+) is not NULL,
?bits
Int (ten) unsigned not NULL,
?version
Int (one) is not NULL,
?created_at
DateTime DEFAULT NULL,
? PRIMARY KEY (id
),
? UNIQUE KEYhash
(hash
),
? KEYheight
(height
)
) Engine=innodb DEFAULT Charset=utf8;
/!40101 SET character_set_client = @saved_cs_client/;
--
--Table structure for table
found_nmc_blocks
DROP TABLE IF EXISTS found_nmc_blocks
;
/!40101 SET @saved_cs_client??? = @ @character_set_client /;
/!40101 SET character_set_client = UTF8 /;
CREATE TABLE found_nmc_blocks
(
? id
Int (one) not NULL auto_increment,
? bitcoin_block_hash
char (+) is not NULL,
? aux_block_hash
char (+) is not NULL,
? aux_pow
Text Not NULL,
? is_orphaned
tinyint (4) not NULL DEFAULT ' 0 ',
? created_at
datetime not NULL,
? PRIMARY KEY ( id
),
? UNIQUE KEY aux_block_hash
( aux_block_hash
)
) Engine=innodb DEFAULT Charset=utf8;
/!40101 SET character_set_client = @saved_cs_client /;
--
--Table structure for table
mining_workers
DROP TABLE IF EXISTSmining_workers
;
/!40101 SET @saved_cs_client??? = @ @character_set_client/;
/!40101 SET character_set_client = UTF8/;
CREATE TABLEmining_workers
(
?worker_id
BigInt () not NULL,
?puid
Int (one) is not NULL,
?group_id
Int (one) is not NULL,
?worker_name
varchar (DEFAULT) NULL,
?accept_1m
BigInt () not NULL DEFAULT ' 0 ',
?accept_5m
BigInt () not NULL DEFAULT ' 0 ',
?accept_15m
BigInt () not NULL DEFAULT ' 0 ',
?reject_15m
BigInt () not NULL DEFAULT ' 0 ',
?accept_1h
BigInt () not NULL DEFAULT ' 0 ',
?reject_1h
BigInt () not NULL DEFAULT ' 0 ',
?accept_count
Int (one) not NULL DEFAULT ' 0 ',
?last_share_ip
char (+) not NULL DEFAULT ' 0.0.0.0 ',
?last_share_time
Timestamp not NULL DEFAULT ' 1970-01-01 00:00:01 ',
?miner_agent
varchar (+) DEFAULT NULL,
?created_at
Timestamp null DEFAULT NULL,
?updated_at
Timestamp null DEFAULT NULL,
? UNIQUE KEYpuid_worker_id
(puid
,worker_id
),
? KEYpuid_group_id
(puid
,group_id
)
) Engine=innodb DEFAULT Charset=utf8;
/!40101 SET character_set_client = @saved_cs_client/;
--
--Table structure for table
mining_workers_tmp
DROP TABLE IF EXISTSmining_workers_tmp
;
/!40101 SET @saved_cs_client??? = @ @character_set_client/;
/!40101 SET character_set_client = UTF8/;
CREATE TABLEmining_workers_tmp
(
?worker_id
BigInt () not NULL,
?puid
Int (one) is not NULL,
?group_id
Int (one) is not NULL,
?worker_name
varchar (DEFAULT) NULL,
?accept_1m
BigInt () not NULL DEFAULT ' 0 ',
?accept_5m
BigInt () not NULL DEFAULT ' 0 ',
?accept_15m
BigInt () not NULL DEFAULT ' 0 ',
?reject_15m
BigInt () not NULL DEFAULT ' 0 ',
?accept_1h
BigInt () not NULL DEFAULT ' 0 ',
?reject_1h
BigInt () not NULL DEFAULT ' 0 ',
?accept_count
Int (one) not NULL DEFAULT ' 0 ',
?last_share_ip
char (+) not NULL DEFAULT ' 0.0.0.0 ',
?last_share_time
Timestamp not NULL DEFAULT ' 1970-01-01 00:00:01 ',
?miner_agent
varchar (+) DEFAULT NULL,
?created_at
Timestamp null DEFAULT NULL,
?updated_at
Timestamp null DEFAULT NULL,
? UNIQUE KEYpuid_worker_id
(puid
,worker_id
),
? KEYpuid_group_id
(puid
,group_id
)
) Engine=innodb DEFAULT Charset=utf8;
/!40101 SET character_set_client = @saved_cs_client/;
/!40103 SET [email protected]_time_zone/;
/!40101 SET [email protected]_sql_mode /;
/!40014 SET [email protected]_foreign_key_checks /;
/!40014 SET [email protected]_unique_checks /;
/!40101 SET [email protected]_character_set_client /;
/!40101 SET [email protected]_character_set_results /;
/!40101 SET [email protected]_collation_connection /;
/!40111 SET [email protected]_sql_notes /;
--Dump completed on 2018-02-22 14:02:44
CREATE TABLE `found_blocks` (`id` int(11) NOT NULL AUTO_INCREMENT,`puid` int(11) NOT NULL,`worker_id` bigint(20) NOT NULL,`worker_full_name` varchar(50) NOT NULL,`job_id` bigint(20) unsigned NOT NULL,`height` int(11) NOT NULL,`is_orphaned` tinyint(4) NOT NULL DEFAULT ‘0‘,`hash` char(64) NOT NULL,`rewards` bigint(20) NOT NULL,`size` int(11) NOT NULL,`prev_hash` char(64) NOT NULL,`bits` int(10) unsigned NOT NULL,`version` int(11) NOT NULL,`created_at` datetime DEFAULT NULL,PRIMARY KEY (`id`),UNIQUE KEY `hash` (`hash`),KEY `height` (`height`)) ENGINE=InnoDB DEFAULT CHARSET=utf8;
Brother even block chain tutorial Btcpool The source code analysis of the mine pool Blockmaker module parsing