Brother even block chain tutorial Btcpool The source code analysis of the mine pool Blockmaker module parsing

Source: Internet
Author: User

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(
?idInt (one) not NULL auto_increment,
?puidInt (one) is not NULL,
?worker_idBigInt () not NULL,
?worker_full_namevarchar (not NULL),
?job_idbigint (unsigned) not NULL,
?heightInt (one) is not NULL,
?is_orphanedtinyint (4) not NULL DEFAULT ' 0 ',
?hashchar (+) is not NULL,
?rewardsBigInt () not NULL,
?sizeInt (one) is not NULL,
?prev_hashchar (+) is not NULL,
?bitsInt (ten) unsigned not NULL,
?versionInt (one) is not NULL,
?created_atDateTime 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 (
? idInt (one) not NULL auto_increment,
? bitcoin_block_hashchar (+) is not NULL,
? aux_block_hashchar (+) is not NULL,
? aux_powText Not NULL,
? is_orphanedtinyint (4) not NULL DEFAULT ' 0 ',
? created_atdatetime 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_idBigInt () not NULL,
?puidInt (one) is not NULL,
?group_idInt (one) is not NULL,
?worker_namevarchar (DEFAULT) NULL,
?accept_1mBigInt () not NULL DEFAULT ' 0 ',
?accept_5mBigInt () not NULL DEFAULT ' 0 ',
?accept_15mBigInt () not NULL DEFAULT ' 0 ',
?reject_15mBigInt () not NULL DEFAULT ' 0 ',
?accept_1hBigInt () not NULL DEFAULT ' 0 ',
?reject_1hBigInt () not NULL DEFAULT ' 0 ',
?accept_countInt (one) not NULL DEFAULT ' 0 ',
?last_share_ipchar (+) not NULL DEFAULT ' 0.0.0.0 ',
?last_share_timeTimestamp not NULL DEFAULT ' 1970-01-01 00:00:01 ',
?miner_agentvarchar (+) DEFAULT NULL,
?created_atTimestamp null DEFAULT NULL,
?updated_atTimestamp 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_idBigInt () not NULL,
?puidInt (one) is not NULL,
?group_idInt (one) is not NULL,
?worker_namevarchar (DEFAULT) NULL,
?accept_1mBigInt () not NULL DEFAULT ' 0 ',
?accept_5mBigInt () not NULL DEFAULT ' 0 ',
?accept_15mBigInt () not NULL DEFAULT ' 0 ',
?reject_15mBigInt () not NULL DEFAULT ' 0 ',
?accept_1hBigInt () not NULL DEFAULT ' 0 ',
?reject_1hBigInt () not NULL DEFAULT ' 0 ',
?accept_countInt (one) not NULL DEFAULT ' 0 ',
?last_share_ipchar (+) not NULL DEFAULT ' 0.0.0.0 ',
?last_share_timeTimestamp not NULL DEFAULT ' 1970-01-01 00:00:01 ',
?miner_agentvarchar (+) DEFAULT NULL,
?created_atTimestamp null DEFAULT NULL,
?updated_atTimestamp 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.