Skip to content
Permalink
Browse files

add configuration to control flush db rate

  • Loading branch information...
BTC.com
BTC.com committed Oct 9, 2019
1 parent 9edc5a2 commit 4368234bd392f43bd2034848905fd0f514fee8d5
Showing with 11 additions and 2 deletions.
  1. +1 −1 src/ShareLogParser.h
  2. +9 −1 src/ShareLogParser.inl
  3. +1 −0 src/ckb/cfg/slparser.cfg
@@ -101,7 +101,7 @@ class ShareLogParserT : public ShareLogParser {
zstr::ifstream *f_; // file handler
uint8_t *buf_; // fread buffer
// 48 * 1000000 = 48,000,000 ~ 48 MB
static const size_t kMaxElementsNum_ = 1000000; // num of shares
int32_t kMaxElementsNum_; // num of shares
size_t incompleteShareSize_;
uint32_t bufferlength_;

@@ -152,6 +152,7 @@ ShareLogParserT<SHARE>::ShareLogParserT(
, chainType_(cfg.lookup("sharelog.chain_type").operator string())
, f_(nullptr)
, buf_(nullptr)
, kMaxElementsNum_(1000000)
, incompleteShareSize_(0)
, poolDB_({cfg.lookup("pooldb.host").operator string(),
configLookup<int32_t>(cfg, "pooldb.port", 3306),
@@ -175,7 +176,9 @@ ShareLogParserT<SHARE>::ShareLogParserT(
WorkerKey pkey(0, 0);
if ("CKB" == chainType_) {
rpcUrl_ = cfg.lookup("sharelog.rpcurl").operator string();
LOG(INFO) << "chaintype : " << chainType_ << " RPCURL : " << rpcUrl_;
cfg.lookupValue("sharelog.max_elements_num", kMaxElementsNum_);
LOG(INFO) << "chaintype : " << chainType_ << " RPCURL : " << rpcUrl_
<< "max_elements_num : " << kMaxElementsNum_;
workersStats_[pkey] = std::make_shared<ShareStatsDay<SHARE>>(rpcUrl_);
} else {
workersStats_[pkey] = std::make_shared<ShareStatsDay<SHARE>>();
@@ -1225,6 +1228,11 @@ void ShareLogParserServerT<SHARE>::runThreadShareLogParser() {
nonShareCounter++;
break;
}
if("CKB" == chainType_ && time(nullptr) > lastFlushDBTime + kFlushDBInterval_) {
DLOG(INFO) << "flush sharelog to DB";
shareLogParser->flushToDB(); // will wait util all data flush to DB
lastFlushDBTime = time(nullptr);
}
nonShareCounter = 0;
DLOG(INFO) << "process share: " << shareNum;
}
@@ -15,6 +15,7 @@ sharelog = {
chain_type = "CKB";
data_dir = "/work/btcpool/data";
rpcurl = "http://localhost:8114";//get blockreward from ckb-node
max_elements_num = 50000;//
};

#

0 comments on commit 4368234

Please sign in to comment.
You can’t perform that action at this time.