Blockchain tutorial btcpool source code analysis slparser

Source: Internet
Author: User
Btcpool-slparser (share log parser) module analysis core mechanism Summary
  • Three functions are supported:
    ??Specify the date and UID to print the share information of the user specified by the specified date to stdout.
    ????
    When uid = 0, the share information of all users on the specified date is printed.
    ??Specify date but no UID, read sharelog of the specified date, and write the statistics to the database.
    ????
    Statistics by worker, user, and pool: accept1h, accept1d, score1h, score1d, reject1h, and reject1d
    ????The database only retains statistics for the last three months
    ??
    If neither date nor uid is specified, the system listens for file changes, reads share and statistics, and writes data to the database every 15 seconds.
    ???? * Start the HTTPd service at the same time and enable serverstatus and workerstatus.
Use the slparser command
Slparser-C slparser. CFG-l log_dirslparser-C slparser. CFG-l log_dir2-D 20160830 slparser-C slparser. CFG-l log_dir3-D 20160830-u puid #-C specifies the slparser configuration file #-L specifies the log directory #-D specifies the date #-u specifies the puid (that is, userid ), when userid is 0, dump all, and> 0, only the sharelog of the specified userid is output.
Slparser. cfg configuration file
Slparserhttpd ={# specify IP address and port IP = "0.0.0.0"; Port = 8081; # flush_db_interval = 15 ;}; # specify the sharelog file path sharelog = {data_dir = "/data/sharelog" ;}; # Database Configuration, table. stats_xxxxpooldb = {Host = ""; Port = 3306; username = "dbusername"; Password = "dbpassword"; dbname = "";};
Slparser Flowchart

Bpool_local_stats_db database structure

Bpool_local_stats_db.txt

``c++<br/>DROP TABLE IF EXISTSStats_pool_day;<br/>CREATE TABLEStats_pool_day(<br/>Dayint(11) NOT NULL,<br/>Pai_acceptbigint(20) NOT NULL DEFAULT ‘0‘,<br/>Pai_rejectbigint(20) NOT NULL DEFAULT ‘0‘,<br/>Reject_ratedouble NOT NULL DEFAULT ‘0‘,<br/>Scoredecimal(35,25) NOT NULL DEFAULT ‘0.0000000000000000000000000‘,<br/>Earnbigint(20) NOT NULL DEFAULT ‘0‘,<br/>Luckydouble NOT NULL DEFAULT ‘0‘,<br/>Created_attimestamp NULL DEFAULT NULL,<br/>Updated_attimestamp NULL DEFAULT NULL,<br/>UNIQUE KEYDay(Day ')
) Engine = InnoDB default charset = utf8;

Drop table if existsstats_pool_hour;
Create Tablestats_pool_hour(
hourINT (11) not null,
share_acceptBigint (20) not null default '0 ',
share_rejectBigint (20) not null default '0 ',
reject_rateDouble not null default '0 ',
scoreDecimal (35,25) not null default '0. 100 ',
earnBigint (20) not null default '0 ',
created_atTimestamp null default null,
updated_atTimestamp null default null,
Unique keyhour(hour)
) Engine = InnoDB default charset = utf8;

Drop table if existsstats_users_day;
Create Tablestats_users_day(
puidINT (11) not null,
dayINT (11) not null,
share_acceptBigint (20) not null default '0 ',
share_rejectBigint (20) not null default '0 ',
reject_rateDouble not null default '0 ',
scoreDecimal (35,25) not null default '0. 100 ',
earnBigint (20) not null default '0 ',
created_atTimestamp null default null,
updated_atTimestamp null default null,
Unique keypuid_day(puid,day)
) Engine = InnoDB default charset = utf8;

Drop table if existsstats_users_hour;
Create Tablestats_users_hour(
puidINT (11) not null,
hourINT (11) not null,
share_acceptBigint (20) not null default '0 ',
share_rejectBigint (20) not null default '0 ',
reject_rateDouble not null default '0 ',
scoreDecimal (35,25) not null default '0. 100 ',
earnBigint (20) not null default '0 ',
created_atTimestamp null default null,
updated_atTimestamp null default null,
Unique keypuid_hour(puid,hour),
Keyhour(hour)
) Engine = InnoDB default charset = utf8;

Drop table if existsstats_workers_day;
Create Tablestats_workers_day(
puidINT (11) not null,
worker_idBigint (20) not null,
dayINT (11) not null,
share_acceptBigint (20) not null default '0 ',
share_rejectBigint (20) not null default '0 ',
reject_rateDouble not null default '0 ',
scoreDecimal (35,25) not null default '0. 100 ',
earnBigint (20) not null default '0 ',
created_atTimestamp null default null,
updated_atTimestamp null default null,
Unique keypuid_worker_id_day(puid,worker_id,day),
Keyday(day)
) Engine = InnoDB default charset = utf8;

Drop table if existsstats_workers_hour;
Create Tablestats_workers_hour(
puidINT (11) not null,
worker_idBigint (20) not null,
hourINT (11) not null,
share_acceptBigint (20) not null default '0 ',
share_rejectBigint (20) not null default '0 ',
reject_rateDouble not null default '0 ',
scoreDecimal (35,25) not null default '0. 100 ',
earnBigint (20) not null default '0 ',
created_atTimestamp null default null,
updated_atTimestamp null default null,
Unique keypuid_worker_id_hour(puid,worker_id,hour),
Keyhour(hour)
) Engine = InnoDB default charset = utf8;

Blockchain tutorial btcpool source code analysis slparser

Related Article

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.