Skip to content
Permalink
Browse files

Remove all "l" from string formatter (e.g. %ld -> %d). Need review an…

…d test.
  • Loading branch information...
SwimmingTiger committed Mar 21, 2019
1 parent 3775ffc commit 7726118fecd8cd87de1f7ed13517fbb89d7fccac
@@ -430,7 +430,7 @@ void ShareLogParserT<SHARE>::generateHoursData(
const double earn = stats->earn1h_[i];

valuesStr = Strings::Format(
"%s%d,%u,%u,%lf,'%s',%0.0lf,'%s','%s'",
"%s%d,%u,%u,%f,'%s',%0.0lf,'%s','%s'",
extraValues.c_str(),
hour,
accept,
@@ -573,7 +573,7 @@ void ShareLogParserT<SHARE>::generateDailyData(
const double earn = stats->earn1d_;

valuesStr = Strings::Format(
"%s%d,%u,%u,%lf,'%s',%0.0lf,'%s','%s'",
"%s%d,%u,%u,%f,'%s',%0.0lf,'%s','%s'",
extraValues.c_str(),
day,
accept,
@@ -897,7 +897,7 @@ void ShareLogParserServerT<SHARE>::getShareStats(
Strings::EvBufferAdd(
evb,
"%s{\"hour\":%d,\"accept\":%u,\"reject\":%u"
",\"reject_rate\":%lf,\"earn\":%0.0lf}",
",\"reject_rate\":%f,\"earn\":%0.0lf}",
(j == 0 ? "" : ","),
hour,
s->shareAccept_,
@@ -1062,12 +1062,12 @@ void ShareLogParserServerT<SHARE>::httpdServerStatus(
"\"data\":{\"uptime\":\"%04u d %02u h %02u m %02u s\","
"\"request\":%u,\"repbytes\":%u"
",\"pool\":{\"today\":{"
"\"hashrate_t\":%lf,\"accept\":%u"
"\"hashrate_t\":%f,\"accept\":%u"
",\"reject\":%u"
",\"reject_rate\":%lf,\"earn\":%0.0lf},"
"\"curr_hour\":{\"hashrate_t\":%lf,\"accept\":%u"
",\"reject_rate\":%f,\"earn\":%0.0lf},"
"\"curr_hour\":{\"hashrate_t\":%f,\"accept\":%u"
",\"reject\":%u"
",\"reject_rate\":%lf,\"earn\":%0.0lf}}"
",\"reject_rate\":%f,\"earn\":%0.0lf}}"
"}}",
s.uptime_ / 86400,
(s.uptime_ % 86400) / 3600,
@@ -198,9 +198,9 @@ void ClientContainerBeam::consumeSolvedShare(rd_kafka_message_t *rkmessage) {
", `rewards`, `block_bits`"
", `created_at`) "
"VALUES("
" %ld, %d"
" %d, %d"
", '%s'"
", %lu, '%s'"
", %u, '%s'"
", '%s', '%s'"
", %d"
", '%s'"
@@ -131,7 +131,7 @@ string StratumJobBitcoin::serializeToJson() const {
",\"height\":%d,\"coinbase1\":\"%s\",\"coinbase2\":\"%s\""
",\"merkleBranch\":\"%s\""
",\"nVersion\":%d,\"nBits\":%u,\"nTime\":%u"
",\"minTime\":%u,\"coinbaseValue\":%lld"
",\"minTime\":%u,\"coinbaseValue\":%d"
",\"witnessCommitment\":\"%s\""
#ifdef CHAIN_TYPE_UBTC
",\"rootStateHash\":\"%s\""
@@ -194,7 +194,7 @@ class ShareBitcoin : public sharebase::BitcoinMsg {
return Strings::Format(
"share(jobId: %u, ip: %s, userId: %d, "
"workerId: %d, time: %u/%s, height: %u, "
"blkBits: %08x/%lf, shareDiff: %u, "
"blkBits: %08x/%f, shareDiff: %u, "
"nonce: %08x, sessionId: %08x, "
"versionMask: %08x, "
"status: %d/%s)",
@@ -186,7 +186,7 @@ void StratumMinerBitcoin::handleExMessage_SubmitShare(
// debug
DLOG(INFO) << Strings::Format(
"[agent] shortJobId: %02x, sessionId: %08x, "
"exNonce2: %016llx, nonce: %08x, time: %08x, versionMask: %08x",
"exNonce2: %016x, nonce: %08x, time: %08x, versionMask: %08x",
shortJobId,
(uint32_t)sessionId,
fullExtraNonce2,
@@ -210,7 +210,7 @@ void StratumMinerBitcoin::handleRequest_Submit(
auto &server = session.getServer();
auto &worker = session.getWorker();

const string extraNonce2Hex = Strings::Format("%016llx", extraNonce2);
const string extraNonce2Hex = Strings::Format("%016x", extraNonce2);
assert(extraNonce2Hex.length() / 2 == kExtraNonce2Size_);

// a function to log rejected stale share
@@ -131,7 +131,7 @@ void BlockMakerBytom::_saveBlockToDBThread(
", `worker_full_name`"
", `height`, `hash`, `rewards`"
", `network_diff`, `created_at`)"
" VALUES (%ld,%d,'%s',%lu,'%s',%d,%u,'%s');",
" VALUES (%d,%d,'%s',%u,'%s',%d,%u,'%s');",
worker.userId_,
worker.workerHashId_,
// filter again, just in case
@@ -86,8 +86,8 @@ void ServerBytom::sendSolvedShare2Kafka(
uint64_t networkDiff,
const StratumWorker &worker) {
string msg = Strings::Format(
"{\"nonce\":%lu,\"header\":\"%s\","
"\"height\":%lu,\"networkDiff\":%u,\"userId\":%ld,"
"{\"nonce\":%u,\"header\":\"%s\","
"\"height\":%u,\"networkDiff\":%u,\"userId\":%d,"
"\"workerId\":%d,\"workerFullName\":\"%s\"}",
nonce,
strHeader.c_str(),
@@ -198,7 +198,7 @@ class ShareDecred : public sharebase::DecredMsg {
return Strings::Format(
"share(jobId: %u, ip: %s, userId: %d, "
"workerId: %d, time: %u/%s, height: %u, "
"blkBits: %08x/%lf, shareDiff: %u, "
"blkBits: %08x/%f, shareDiff: %u, "
"voters: %u, status: %d/%s)",
jobid(),
ip().c_str(),
@@ -408,7 +408,7 @@ void BlockMakerEth::saveBlockToDB(
", `height`, `hash`, `hash_no_nonce`, `nonce`"
", `rewards`"
", `network_diff`, `created_at`)"
" VALUES (%ld, %d"
" VALUES (%d, %d"
", '%s', '%s', %u"
", '%s', '%s', '%s'"
", %d, %u, '%s');",
@@ -238,9 +238,9 @@ string GwMakerHandlerEth::constructRawMsg(JsonNode &r) {
"\"target\":\"%s\","
"\"hHash\":\"%s\","
"\"sHash\":\"%s\","
"\"height\":%ld,"
"\"uncles\":%lu,"
"\"transactions\":%lu,"
"\"height\":%d,"
"\"uncles\":%u,"
"\"transactions\":%u,"
"\"gasUsedPercent\":%f"
"%s"
"}",
@@ -36,7 +36,7 @@ string StratumClientEth::constructShare() {
// "0x52fdd9e9a796903c6b88af4192717e77d9a9c6fa6a1366540b65e6bcfa9069aa"]}
string s = Strings::Format(
"{\"id\": 4, \"method\": \"mining.submit\", "
"\"params\": [\"%s\",\"%s\",\"0x%016llx\",\"%s\",\"%s\"]}\n",
"\"params\": [\"%s\",\"%s\",\"0x%016x\",\"%s\",\"%s\"]}\n",
workerFullName_.c_str(),
latestJobId_.c_str(),
extraNonce2_,
@@ -541,9 +541,9 @@ void ServerEth::sendSolvedShare2Kafka(
const boost::optional<uint32_t> &sessionId) {
string msg = Strings::Format(
"{\"nonce\":\"%s\",\"header\":\"%s\",\"mix\":\"%s\""
",\"height\":%lu,\"networkDiff\":%u"
",\"height\":%u,\"networkDiff\":%u"
"%s"
",\"userId\":%ld"
",\"userId\":%d"
",\"workerId\":%d"
",\"workerFullName\":\"%s\""
",\"chain\":\"%s\"}",
@@ -127,7 +127,7 @@ void StratumSessionEth::sendMiningNotifyWithId(
strNotify = Strings::Format(
"{\"id\":%s,\"method\":\"mining.notify\","
"\"params\":[\"%s\",\"%s\",\"%s\",\"%s\",%s],"
"\"height\":%lu}\n",
"\"height\":%u}\n",
idStr.c_str(),
header.c_str(),
header.c_str(),
@@ -148,7 +148,7 @@ void StratumSessionEth::sendMiningNotifyWithId(
// nonce cannot start with 0x because of
// a compatibility issue with AntMiner E3.
"\"%06x\"],"
"\"height\":%lu}\n",
"\"height\":%u}\n",
idStr.c_str(),
header.c_str(),
seed.c_str(),
@@ -167,7 +167,7 @@ void StratumSessionEth::sendMiningNotifyWithId(
// }
strNotify += Strings::Format(
"{\"id\":%s,\"method\":\"mining.set_difficulty\","
"\"params\":[%lf]}\n",
"\"params\":[%f]}\n",
idStr.c_str(),
Eth_DiffToNicehashDiff(currentJobDiff_));
nicehashLastSentDiff_ = currentJobDiff_;
@@ -185,7 +185,7 @@ void StratumSessionEth::sendMiningNotifyWithId(
strNotify += Strings::Format(
"{\"id\":%s,\"method\":\"mining.notify\","
"\"params\":[\"%s\",\"%s\",\"%s\",%s],"
"\"height\":%lu}\n",
"\"height\":%u}\n",
idStr.c_str(),
header.c_str(),
seed.c_str(),
@@ -209,8 +209,8 @@ void ClientContainerGrin::consumeSolvedShare(rd_kafka_message_t *rkmessage) {
", `rewards`, `job_id`"
", `created_at`) "
"VALUES("
" %ld, %d, '%s'"
", %lu, '%s'"
" %d, %d, '%s'"
", %u, '%s'"
", '%u', '%016x'"
", %d, '%u', '%s');",
userId,
@@ -126,7 +126,7 @@ class ShareSia : public sharebase::SiaMsg {
return Strings::Format(
"share(jobId: %u, ip: %s, userId: %d, "
"workerId: %d, time: %u/%s, height: %u, "
"blkBits: %08x/%lf, shareDiff: %u, "
"blkBits: %08x/%f, shareDiff: %u, "
"status: %d/%s)",
jobid(),
ip().c_str(),
@@ -148,7 +148,7 @@ TEST(SIMULATOR, miner) {
{
sbuf = Strings::Format(
"{\"params\": "
"[\"%s.simulator_test\",\"%s\",\"%016llx\",\"%08x\",\"%08x\"]"
"[\"%s.simulator_test\",\"%s\",\"%016x\",\"%08x\",\"%08x\"]"
",\"id\":4,\"method\": \"mining.submit\"}\n",
userName.c_str(),
latestJobId.c_str(),
@@ -170,7 +170,7 @@ TEST(SIMULATOR, miner) {
{
sbuf = Strings::Format(
"{\"params\": "
"[\"%s.simulator_test\",\"%s\",\"%016llx\",\"%08x\",\"%08x\"]"
"[\"%s.simulator_test\",\"%s\",\"%016x\",\"%08x\",\"%08x\"]"
",\"id\":4,\"method\": \"mining.submit\"}\n",
userName.c_str(),
latestJobId.c_str(),
@@ -189,7 +189,7 @@ TEST(SIMULATOR, miner) {
nTime = time(nullptr) - 86400;
sbuf = Strings::Format(
"{\"params\": "
"[\"%s.simulator_test\",\"%s\",\"%016llx\",\"%08x\",\"%08x\"]"
"[\"%s.simulator_test\",\"%s\",\"%016x\",\"%08x\",\"%08x\"]"
",\"id\":4,\"method\": \"mining.submit\"}\n",
userName.c_str(),
latestJobId.c_str(),
@@ -208,7 +208,7 @@ TEST(SIMULATOR, miner) {
nTime = time(nullptr) + 3600 * 2;
sbuf = Strings::Format(
"{\"params\": "
"[\"%s.simulator_test\",\"%s\",\"%016llx\",\"%08x\",\"%08x\"]"
"[\"%s.simulator_test\",\"%s\",\"%016x\",\"%08x\",\"%08x\"]"
",\"id\":4,\"method\": \"mining.submit\"}\n",
userName.c_str(),
latestJobId.c_str(),
@@ -227,7 +227,7 @@ TEST(SIMULATOR, miner) {
nTime = time(nullptr);
sbuf = Strings::Format(
"{\"params\": "
"[\"%s.simulator_test\",\"%s\",\"%016llx\",\"%08x\",\"%08x\"]"
"[\"%s.simulator_test\",\"%s\",\"%016x\",\"%08x\",\"%08x\"]"
",\"id\":4,\"method\": \"mining.submit\"}\n",
userName.c_str(),
"s982asd2das",
@@ -187,7 +187,7 @@ struct ShareBitcoinV2 {
return StringFormat(
"share(jobId: %u, ip: %s, userId: %d, "
"workerId: %d, time: %u/%s, height: %u, "
"blkBits: %08x/%lf, shareDiff: %u, "
"blkBits: %08x/%f, shareDiff: %u, "
"status: %d/%s)",
jobId_,
ip_.toString().c_str(),
@@ -57,8 +57,8 @@ void usage() {
fprintf(
stderr,
"Usage:\n\tsharelog_to_parquet -i \"<input-sharelog-v1-file.bin>\" -o "
"\"<output-parquet-file.bin>\" [-n %ld]\n",
DEFAULT_NUM_ROWS_PER_ROW_GROUP);
"\"<output-parquet-file.bin>\" [-n %d]\n",
(int)DEFAULT_NUM_ROWS_PER_ROW_GROUP);
}

class ParquetWriter {

0 comments on commit 7726118

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