兄弟连区块链教程btcpool矿池源码分析slparser

栏目: 数据库 · 发布时间: 7年前

btcpool矿池-slparser(share log parser)模块解析

核心机制总结

  • 支持三种功能:

    • 指定Date和UID,将打印指定日期指定用户的share信息到stdout

      • UID=0时,将打印指定日期所有用户的share信息
    • 指定Date但未指定UID,读取指定日期sharelog,统计数据并写入数据库

      • 按Worker、user、pool三个维度统计:Accept1h、Accept1d、score1h、score1d、Reject1h、Reject1d
      • 数据库仅保留最近3个月统计数据
    • 如果Date和UID均未指定,将监听文件变化,读取share并统计数据,每15秒写入数据库

      • 同时启动Httpd服务,开放ServerStatus和WorkerStatus

slparser命令使用

slparser -c slparser.cfg -l log_dir
slparser -c slparser.cfg -l log_dir2 -d 20160830
slparser -c slparser.cfg -l log_dir3 -d 20160830 -u puid
#-c指定slparser配置文件
#-l指定日志目录
#-d指定日期
#-u指定PUID(即userId),userId为0时dump all, >0时仅输出指定userId的sharelog
slparser.cfg配置文件
slparserhttpd = {
#指定IP和端口
ip = "0.0.0.0";
port = 8081;

#每间隔15s写库
flush_db_interval = 15;
};

#指定sharelog文件路径
sharelog = {
data_dir = "/data/sharelog";
};

#数据库配置,表为table.stats_xxxx
pooldb = {
host = "";
port = 3306;
username = "dbusername";
password = "dbpassword";
dbname = "";
};
slparser流程图

![bpo][1]ol_local_stats_db数据库结构
bpool_local_stats_db.txt
DROP TABLE IF EXISTS `stats_pool_day`;
CREATE TABLE `stats_pool_day` (
`day` int(11) NOT NULL,
`share_accept` bigint(20) NOT NULL DEFAULT '0',
`share_reject` bigint(20) NOT NULL DEFAULT '0',
`reject_rate` double NOT NULL DEFAULT '0',
`score` decimal(35,25) NOT NULL DEFAULT '0.0000000000000000000000000',
`earn` bigint(20) NOT NULL DEFAULT '0',
`lucky` double NOT NULL DEFAULT '0',
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL,
UNIQUE KEY `day` (`day`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

DROP TABLE IF EXISTS `stats_pool_hour`;
CREATE TABLE `stats_pool_hour` (
`hour` int(11) NOT NULL,
`share_accept` bigint(20) NOT NULL DEFAULT '0',
`share_reject` bigint(20) NOT NULL DEFAULT '0',
`reject_rate` double NOT NULL DEFAULT '0',
`score` decimal(35,25) NOT NULL DEFAULT '0.0000000000000000000000000',
`earn` bigint(20) NOT NULL DEFAULT '0',
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL,
UNIQUE KEY `hour` (`hour`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

DROP TABLE IF EXISTS `stats_users_day`;
CREATE TABLE `stats_users_day` (
`puid` int(11) NOT NULL,
`day` int(11) NOT NULL,
`share_accept` bigint(20) NOT NULL DEFAULT '0',
`share_reject` bigint(20) NOT NULL DEFAULT '0',
`reject_rate` double NOT NULL DEFAULT '0',
`score` decimal(35,25) NOT NULL DEFAULT '0.0000000000000000000000000',
`earn` bigint(20) NOT NULL DEFAULT '0',
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL,
UNIQUE KEY `puid_day` (`puid`,`day`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

DROP TABLE IF EXISTS `stats_users_hour`;
CREATE TABLE `stats_users_hour` (
`puid` int(11) NOT NULL,
`hour` int(11) NOT NULL,
`share_accept` bigint(20) NOT NULL DEFAULT '0',
`share_reject` bigint(20) NOT NULL DEFAULT '0',
`reject_rate` double NOT NULL DEFAULT '0',
`score` decimal(35,25) NOT NULL DEFAULT '0.0000000000000000000000000',
`earn` bigint(20) NOT NULL DEFAULT '0',
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL,
UNIQUE KEY `puid_hour` (`puid`,`hour`),
KEY `hour` (`hour`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

DROP TABLE IF EXISTS `stats_workers_day`;
CREATE TABLE `stats_workers_day` (
`puid` int(11) NOT NULL,
`worker_id` bigint(20) NOT NULL,
`day` int(11) NOT NULL,
`share_accept` bigint(20) NOT NULL DEFAULT '0',
`share_reject` bigint(20) NOT NULL DEFAULT '0',
`reject_rate` double NOT NULL DEFAULT '0',
`score` decimal(35,25) NOT NULL DEFAULT '0.0000000000000000000000000',
`earn` bigint(20) NOT NULL DEFAULT '0',
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL,
UNIQUE KEY `puid_worker_id_day` (`puid`,`worker_id`,`day`),
KEY `day` (`day`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

DROP TABLE IF EXISTS `stats_workers_hour`;
CREATE TABLE `stats_workers_hour` (
`puid` int(11) NOT NULL,
`worker_id` bigint(20) NOT NULL,
`hour` int(11) NOT NULL,
`share_accept` bigint(20) NOT NULL DEFAULT '0',
`share_reject` bigint(20) NOT NULL DEFAULT '0',
`reject_rate` double NOT NULL DEFAULT '0',
`score` decimal(35,25) NOT NULL DEFAULT '0.0000000000000000000000000',
`earn` bigint(20) NOT NULL DEFAULT '0',
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL,
UNIQUE KEY `puid_worker_id_hour` (`puid`,`worker_id`,`hour`),
KEY `hour` (`hour`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
欢迎继续关注兄弟连区块链教程分享!

以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

凸优化

凸优化

Stephen Boyd、Lieven Vandenberghe / 王书宁、许鋆、黄晓霖 / 清华大学出版社 / 2013-1 / 99.00元

《信息技术和电气工程学科国际知名教材中译本系列:凸优化》内容非常丰富。理论部分由4章构成,不仅涵盖了凸优化的所有基本概念和主要结果,还详细介绍了几类基本的凸优化问题以及将特殊的优化问题表述为凸优化问题的变换方法,这些内容对灵活运用凸优化知识解决实际问题非常有用。应用部分由3章构成,分别介绍凸优化在解决逼近与拟合、统计估计和几何关系分析这三类实际问题中的应用。算法部分也由3章构成,依次介绍求解无约束......一起来看看 《凸优化》 这本书的介绍吧!

在线进制转换器
在线进制转换器

各进制数互转换器

SHA 加密
SHA 加密

SHA 加密工具

HSV CMYK 转换工具
HSV CMYK 转换工具

HSV CMYK互换工具