Skip to content

Terminal transcript #1539

Description

@zaraiskais-byte

~/caesar-czr-internal-real $
cd "$HOME/caesar-czr-internal-real" || exit 1
set -eu

echo "===== CZR-XOF-APEX | BUILD CHECK ====="

echo "--- Current changes ---"
git status --short

echo
echo "--- Hashrate field ---"
grep -n -B 5 -A 12 "hashStr" include/caesar/http_rpc.h
pp || true

echo
echo "--- Badge ---"
grep -n -B 4 -A 12 "CZR LIVE | ACTIVE" include/caesar/
http_rpc.hpp || true

echo
echo "--- Worker telemetry ---"
grep -R -n -E 'hashrate|hash_rate|hashes_per_second|H/
s'
include/caesar src --include='.hpp' --include='.cp
p'
2>/dev/null | head -60 || true

echo
echo "--- Diff validation ---"
git diff --check

echo
echo "--- Build ---"
cmake --build build-web --target caesar_web caesar_wor
ker -j2

echo
echo "BUILD=PASS"
echo "SERVER_RESTART=NO"
echo "WALLET_DATA_TOUCHED=NO"
echo "CHAIN_DATA_TOUCHED=NO"
===== CZR-XOF-APEX | BUILD CHECK =====
--- Current changes ---
M CMakeLists.txt
M include/caesar/http_rpc.hpp
M include/caesar/node.hpp
M include/caesar/p2p_peer_manager.hpp
M include/caesar/p2p_protocol.hpp
M include/caesar/p2p_relay.hpp
M include/caesar/p2p_server.hpp
M tests/p2p_lifecycle_race_test.cpp
?? fix_pool_badge.sh
?? include/caesar/http_rpc.hpp.async-mining-route-back
up
?? include/caesar/http_rpc.hpp.mine-route-backup
?? include/caesar/node.hpp.async-mining-backup
?? include/caesar/node.hpp.mining-core-backup
?? include/caesar/node.hpp.pre-pool-relay-lockfix-2026
1008-034203
?? include/caesar/p2p_peer_discovery.hpp
?? tests/p2p_discovery_scheduler_test.cpp
?? tests/p2p_peer_discovery_test.cpp
?? unspent

--- Hashrate field ---
6601- const myShares = totalShares;
6602-
6603-
6604-
6605- // No measured hashrate telemetry is availabl
e.
6606: const hashStr = '—';
6607: var hh=$('heroHash'); if(hh) hh.textContent =
hashStr;
6608-
6609- var hb=$('heroBlocksToday'); if(hb) hb.textCo
ntent = String(myBlocks);
6610-
6611- var hs=$('heroSharesToday'); if(hs) hs.textCo
ntent = String(myShares);
6612-
6613-
6614-
6615- // Progress: 50 blocks/day target (as example
)
6616-
6617- const targetBlocks = 50;
6618-
6619- const pct = Math.min(100, Math.round((myBlock
s/targetBlocks)*100));

--- Badge ---
9977- var active = p.workers.filter(function(w){
9978- return w && w.active === true;
9979- }).length;
9980- setBadge(
9981: 'CZR LIVE | ACTIVE: ' + active + '/' + p.
workers.length,
9982- '#087f23'
9983- );
9984- })
9985- .catch(function(e){
9986- setBadge(
9987- 'CZR API ERROR: ' + String(e.message || e
),
9988- '#b00020'
9989- );
9990- });
9991- }
9992-
9993- checkCzrApi();

--- Worker telemetry ---
include/caesar/http_rpc.hpp:5784:

H/s

include/caesar/http_rpc.hpp:6605: // No measured ha
shrate telemetry is available.
include/caesar/http_rpc.hpp:10110:
H/s

--- Diff validation ---

--- Build ---
[ 50%] Building CXX object CMakeFiles/caesar_web.dir/s
rc/web.cpp.o
In file included from /data/data/com.termux/files/home
/caesar-czr-internal-real/src/web.cpp:11:
In file included from /data/data/com.termux/files/home
/caesar-czr-internal-real/include/caesar/http_rpc.hpp:
51:
/data/data/com.termux/files/home/caesar-czr-internal-r
eal/third_party/httplib.h:3432:42: warning:
identifier '_t' preceded by whitespace in a
literal operator declaration is deprecated
[-Wdeprecated-literal-operator]
3432 | inline constexpr unsigned int operator"" _t(co
...
| ~~~~~~~~~~~^~
| operator""_t
1 warning generated.
[100%] Linking CXX executable caesar_web
[100%] Built target caesar_web
[100%] Built target caesar_worker

BUILD=PASS
SERVER_RESTART=NO
WALLET_DATA_TOUCHED=NO
CHAIN_DATA_TOUCHED=NO
~/caesar-czr-internal-real $
cd "$HOME/caesar-czr-internal-real" || exit 1
set -eu

echo "===== 1. WORKER SOURCE FILES ====="
find src include/caesar -maxdepth 3 -type f
( -iname 'worker' -o -iname 'miner' -o -iname '
pool' )
-print

echo
echo "===== 2. HASH LOOP AND SHARE SUBMISSION ====="
grep -R -n -E
'while[[:space:]](|nonce|hash|submit|/api/pool/job
|/api/pool/submit|total_shares'
src include/caesar --include='
.cpp' --include='*.hp
p'
2>/dev/null | head -100 || true

echo
echo "===== 3. WORKER PROCESS ====="
pgrep -af 'caesar_worker' || true

echo
echo "===== 4. BUILD ARTIFACTS ====="
test -x build-web/caesar_web && echo "WEB_BINARY=PASS"

test -x build-web/caesar_worker && echo "WORKER_BINARY
=PASS"

echo
echo "SOURCE_MODIFIED=NO"
echo "SERVER_RESTART=NO"
echo "WALLET_DATA_TOUCHED=NO"
echo "CHAIN_DATA_TOUCHED=NO"
===== 1. WORKER SOURCE FILES =====
src/pool_worker.cpp
include/caesar/mempool_validation.hpp
include/caesar/mempool.hpp
include/caesar/mempool_reorg.hpp
include/caesar/http_rpc.hpp.pre-pool-dedup-20261008-02
5021
include/caesar/node.hpp.pre-pool-relay-lockfix-2026100
8-034203
include/caesar/http_rpc.hpp.pre-pool-job-lock-rootfix2
-20261008-042332

===== 2. HASH LOOP AND SHARE SUBMISSION =====
src/main.cpp:177: while (node.running()) {
src/web.cpp:82: while (true) {
src/web.cpp:118: while (g_running.load() && nod
e.running()) {
src/pool_worker.cpp:65: while ((n = ::recv(fd, buf,
sizeof buf, 0)) > 0) resp.append(buf, n);
src/pool_worker.cpp:154: std::atomicstd::uint64_t
submitted{0};
src/pool_worker.cpp:156: while (!stop.load()) {
src/pool_worker.cpp:158:
"/api/pool/job?address=" + address, "");
src/pool_worker.cpp:169: std::uint64_t nonc
e = static_caststd::uint64_t(tid) * 1000003ULL;
src/pool_worker.cpp:171: while (!stop.load(
) && tested < 50000000ULL) {
src/pool_worker.cpp:172: caesar::Hash25
6 h = caesar::calculate_pow_hash(header_bytes, nonce);
src/pool_worker.cpp:177: << ","
nonce":" << nonce << "}";
src/pool_worker.cpp:179:
"/api/pool/submit", sb.str());
src/pool_worker.cpp:180: submitted.
fetch_add(1);
src/pool_worker.cpp:184: std::cout
<< "[worker:" << tid << "] nonce=" << nonce
src/pool_worker.cpp:186:
<< " total=" << submitted.load() << std::endl;
src/pool_worker.cpp:194: ++nonce; ++tes
ted;
include/caesar/crypto.hpp:39:inline std::string hash_t
o_hex(const Hash256& hash) {
include/caesar/crypto.hpp:43: for (std::uint8_t byt
e : hash)
include/caesar/crypto.hpp:49:inline Hash256 hash_pair(
const Hash256& left, const Hash256& right) {
include/caesar/crypto.hpp:57:inline Hash256 merkle_roo
t(std::vector hashes) {
include/caesar/crypto.hpp:58: if (hashes.empty())
include/caesar/crypto.hpp:61: while (hashes.size()

  1. {
    include/caesar/crypto.hpp:63: next.reserve((has
    hes.size() + 1) / 2);
    include/caesar/crypto.hpp:65: for (std::size_t
    i = 0; i < hashes.size(); i += 2) {
    include/caesar/crypto.hpp:66: const Hash256
    & left = hashes[i];
    include/caesar/crypto.hpp:67: const Hash256
    & right = (i + 1 < hashes.size()) ? hashes[i + 1] : ha
    shes[i];
    include/caesar/crypto.hpp:69: next.push_bac
    k(hash_pair(left, right));
    include/caesar/crypto.hpp:72: hashes = std::mov
    e(next);
    include/caesar/crypto.hpp:75: return hashes.front()
    ;
    include/caesar/transaction.hpp:22: out << hash_
    to_hex(previous_txid) << ':' << output_index;
    include/caesar/transaction.hpp:40: const auto h
    ash = reader.read_bytes(32);
    include/caesar/transaction.hpp:43: input.pr
    evious_txid[i] = hash[i];
    include/caesar/address.hpp:13: const Hash256 second
    = sha256(hash_to_hex(first));
    include/caesar/address.hpp:15: return hash_to_hex(s
    econd).substr(0, 8);
    include/caesar/address.hpp:19: const Hash256 hash =
    sha256(public_key);
    include/caesar/address.hpp:21: const std::string pa
    yload = "CZ1" + hash_to_hex(hash);
    include/caesar/mempool.hpp:22: std::size_t oper
    ator()(const Hash256& hash) const noexcept {
    include/caesar/mempool.hpp:25: for (std::ui
    nt8_t byte : hash) {
    include/caesar/mempool.hpp:145: while (!remaini
    ng.empty()) {
    include/caesar/mempool.hpp:210: while (changed)
    {
    include/caesar/block.hpp:20: Hash256 previous_hash{
    };
    include/caesar/block.hpp:24: std::uint64_t nonce{0}
    ;
    include/caesar/block.hpp:33: for (std::uint8_t
    byte : previous_hash)
    include/caesar/block.hpp:43: writer.write_u64(n
    once);
    include/caesar/block.hpp:49: Hash256 hash() const {
    include/caesar/block.hpp:60: for (auto& byte :
    header.previous_hash)
    include/caesar/block.hpp:70: header.nonce = rea
    der.read_u64();
    include/caesar/block.hpp:172: for (std::uint8_t
    & byte : block.header.previous_hash)
    include/caesar/block.hpp:182: block.header.nonc
    e = reader.read_u64();
    include/caesar/block.hpp:209: Hash256 hash() const
    {
    include/caesar/block.hpp:210: return header.has
    h();
    include/caesar/block.hpp:215: mining_header.non
    ce = 0;
    include/caesar/block.hpp:219: Hash256 pow_hash() co
    nst {
    include/caesar/block.hpp:220: return calculate_
    pow_hash(pow_header(), header.nonce);
    include/caesar/block.hpp:224: return caesar::va
    lidate_pow(pow_header(), header.nonce, header.difficul
    ty);
    include/caesar/block.hpp:290: if (header.previo
    us_hash != previous.hash())
    include/caesar/block.hpp:313: for (std::uin
    t8_t byte : header.previous_hash) {
    include/caesar/block.hpp:339: * th
    e pinned genesis hash for each network. Here
    include/caesar/block.hpp:382: if (current.header.pr
    evious_hash != previous.hash()) {
    include/caesar/block_builder.hpp:17:
    std::uint32_t difficulty, std::uint64_t nonce = 0
    ,
    include/caesar/block_builder.hpp:26: block.head
    er.previous_hash = previous.hash();
    include/caesar/block_builder.hpp:29: block.head
    er.nonce = nonce;
    include/caesar/block_builder.hpp:51: static bool mi
    ne(Block& block, std::uint64_t start_nonce, std::uint6
    4_t max_attempts) {
    include/caesar/block_builder.hpp:55: std::uint6
    4_t found_nonce = 0;
    include/caesar/block_builder.hpp:56: Hash256 fo
    und_hash{};
    include/caesar/block_builder.hpp:58: const bool
    found = mine_pow(block.pow_header(), block.header.dif
    ficulty, start_nonce,
    include/caesar/block_builder.hpp:59:
    max_attempts, found_nonce, found_has
    h);
    include/caesar/block_builder.hpp:64: block.head
    er.nonce = found_nonce;
    include/caesar/block_builder.hpp:66: if (block.
    pow_hash() != found_hash)
    include/caesar/block_builder.hpp:67: throw
    std::runtime_error("PoW hash changed immediately after
    mining");
    include/caesar/coinbase.hpp:26:inline bool is_zero_has
    h(const Hash256& hash) {
    include/caesar/coinbase.hpp:27: for (std::uint8_t b
    yte : hash) {
    include/caesar/coinbase.hpp:48:
    std::uint64_t extra_nonce = 0) {
    include/caesar/coinbase.hpp:67: tx.coinbase_data.re
    size(sizeof(extra_nonce));
    include/caesar/coinbase.hpp:68: for (std::size_t i
    = 0; i < sizeof(extra_nonce); ++i) {
    include/caesar/coinbase.hpp:69: tx.coinbase_dat
    a[i] = static_caststd::uint8_t((extra_nonce >> (i *
    8)) & 0xff);
    include/caesar/coinbase.hpp:91: if (!is_zero_hash(t
    x.inputs[0].previous_txid)) {
    include/caesar/consensus.hpp:35:inline Hash256 calcula
    te_pow_hash(const std::vectorstd::uint8_t& header, s
    td::uint64_t nonce) {
    include/caesar/consensus.hpp:39: writer.write_u64(n
    once);
    include/caesar/consensus.hpp:45: const std::uint64_
    t seed = pow_load64(state, 0) ^ pow_load64(state, 8) ^
    nonce;
    include/caesar/consensus.hpp:51:
    static_caststd::uint64_t(i) * 0x9e3779b97f4a
    7c15ULL ^ nonce);
    include/caesar/consensus.hpp:59: static
    _caststd::size_t(pow_mix64(accumulator ^ memory[i] ^
    nonce ^
    include/caesar/consensus.hpp:85: final_writer.write
    u64(nonce);
    include/caesar/consensus.hpp:94:inline std::uint32_t c
    ount_leading_zero_bits(const Hash256& hash) {
    include/caesar/consensus.hpp:97: for (std::uint8_t
    byte : hash) {
    include/caesar/consensus.hpp:114:inline bool pow_meets
    difficulty(const Hash256& hash, std::uint32_t difficu
    lty) {
    include/caesar/consensus.hpp:118: return count_lead
    ing_zero_bits(hash) >= difficulty;
    include/caesar/consensus.hpp:121:inline bool validate

    pow(const std::vectorstd::uint8_t& header, std::uint
    64_t nonce,
    include/caesar/consensus.hpp:123: return pow_meets

    difficulty(calculate_pow_hash(header, nonce), difficul
    ty);
    include/caesar/consensus.hpp:127:
    std::uint64_t start_nonce, std::uint64_t max_attempts,
    include/caesar/consensus.hpp:128:
    std::uint64_t& found_nonce, Hash256& found_hash) {
    include/caesar/consensus.hpp:133: if (start_non
    ce > std::numeric_limitsstd::uint64_t::max() - i)
    include/caesar/consensus.hpp:136: const std::ui
    nt64_t nonce = start_nonce + i;
    include/caesar/consensus.hpp:138: const Hash256
    hash = calculate_pow_hash(header, nonce);
    include/caesar/consensus.hpp:140: if (pow_meets
    _difficulty(hash, difficulty)) {
    include/caesar/consensus.hpp:141: found_non
    ce = nonce;
    include/caesar/consensus.hpp:142: found_has
    h = hash;
    include/caesar/consensus.hpp:158: * hash satisfies pro
    of of work and the chain offers no meaningful
    include/caesar/consensus.hpp:162: * 8 leading zero bit
    s requires on average 256 hashes per block,
    include/caesar/consensus.hpp:199: while (observ
    ed >= CZR_TARGET_BLOCK_TIME * 2ULL && next > CZR_MIN_D
    IFFICULTY) {

===== 3. WORKER PROCESS =====
21561 ./build-web/caesar_worker --pool http://127.0.0.
1:8443 --address CZ1861ac08ed0cb8705f25b7ea5eb6c75b9f7
c9f8bc7ac06ccbc3e6233595740cc2e1c48f64 --threads 1

===== 4. BUILD ARTIFACTS =====
WEB_BINARY=PASS
WORKER_BINARY=PASS

SOURCE_MODIFIED=NO
SERVER_RESTART=NO
WALLET_DATA_TOUCHED=NO
CHAIN_DATA_TOUCHED=NO
~/caesar-czr-internal-real $ cd "$HOME/caesar-czr-inte
rnal-real" || exit 1
set -eu

echo "===== 1. REAL HASH LOOP ====="
sed -n '130,210p' src/pool_worker.cpp

echo
echo "===== 2. WORKER REGISTRATION / STATS API ====="
grep -n -E -B 5 -A 18
'api/pool/register|api/pool/stats|api/pool/job|api/p
ool/submit'
include/caesar/http_rpc.hpp | head -180

echo
echo "===== 3. WORKER DATA STRUCTURE ====="
grep -n -E -B 4 -A 12
'struct.*Worker|class.*Worker|workers|total_shares'

include/caesar/http_rpc.hpp | head -120

echo
echo "SOURCE_MODIFIED=NO"
echo "WORKER_STOPPED=NO"
echo "SERVER_RESTART=NO"
echo "WALLET_DATA_TOUCHED=NO"
echo "CHAIN_DATA_TOUCHED=NO"
===== 1. REAL HASH LOOP =====
}
if (pool_url.empty() || address.empty()) {
std::cerr << "usage: caesar_worker --pool http
://host:port --address CZ1... [--threads N]\n";
return 1;
}
std::string host;
std::uint16_t port = 0;
if (!parse_host_port(pool_url, host, port)) {
std::cerr << "[worker] invalid pool url\n"; re
turn 1;
}
std::cout << "[worker] pool = " << host << ":" <<
port << "\n";
std::cout << "[worker] address = " << address << "
\n";
std::cout << "[worker] threads = " << threads << "
\n";
{
std::string body = "{"address":"" + address

  • "","worker":"" + name + ""}";
    HttpResult r = http_request(host, port, "POST"
    , "/api/pool/register", body);
    if (!r.ok) {
    std::cerr << "[worker] register failed: "
    << r.status << " " << r.body << "\n";
    return 1;
    }
    std::cout << "[worker] registered\n";
    }
    std::atomic stop{false};
    std::atomicstd::uint64_t accepted{0};
    std::atomicstd::uint64_t submitted{0};
    auto loop = [&](int tid) {
    while (!stop.load()) {
    HttpResult jr = http_request(host, port, "
    GET",
    "/api/pool/jo
    b?address=" + address, "");
    if (!jr.ok) { std::this_thread::sleep_for(
    std::chrono::seconds(2)); continue; }
    std::uint64_t job_id = json_u64(jr.body, "
    job_id");
    std::uint32_t share_diff = static_cast(
    json_u64(jr.body, "share_difficulty"))
    ;
    std::string header_hex = json_str(jr.body,
    "header_hex");
    if (job_id == 0 || header_hex.empty()) {
    std::this_thread::sleep_for(std::chron
    o::seconds(1));
    continue;
    }
    auto header_bytes = hex_to_bytes(header_he
    x);
    std::uint64_t nonce = static_cast<std::uin
    t64_t>(tid) * 1000003ULL;
    std::uint64_t tested = 0;
    while (!stop.load() && tested < 50000000UL
    L) {
    caesar::Hash256 h = caesar::calculate_
    pow_hash(header_bytes, nonce);
    if (caesar::pow_meets_difficulty(h, sh
    are_diff)) {
    std::ostringstream sb;
    sb << "{"address":"" << address
    << """
    << ","job_id":" << job_id
    << ","nonce":" << nonce << "}
    ";
    HttpResult sr = http_request(host,
    port, "POST",
    "/api
    /pool/submit", sb.str());
    submitted.fetch_add(1);
    if (sr.ok && sr.body.find(""credi
    ted":true") != std::string::npos) {
    accepted.fetch_add(1);
    }
    std::cout << "[worker:" << tid <<
    "] nonce=" << nonce
    << " acc=" << accepted.l
    oad()
    << " total=" << submitte
    d.load() << std::endl;
    if (sr.body.find(""stale":true")
    != std::string::npos) {
    std::cout << "[worker:" << tid
    << "] stale job dete
    cted, requesting new job"
    << std::endl;
    break;
    }
    }
    ++nonce; ++tested;
    }
    }
    };
    std::vectorstd::thread ts;
    for (int i = 0; i < threads; ++i) ts.emplace_back(
    loop, i);
    for (auto& t : ts) t.join();
    std::cout << "[worker] done. accepted=" << accepte
    d.load() << "\n";
    return 0;
    }

===== 2. WORKER REGISTRATION / STATS API =====
6573-
6574-async function updateHeroCard(){
6575-
6576- try{
6577-
6578: const stats = await api('/api/pool/stats');
6579-
6580- const status = await api('/api/status');
6581-
6582- if(!stats || !status) return;
6583-
6584- const workers = (stats.workers && Array.isArr
ay(stats.workers)) ? stats.workers : [];
6585- const activeWorkers = workers.filter(w => w &
& w.active === true).length;
6586-
6587- const totalShares = (typeof stats.total_share
s==='number') ? stats.total_shares : 0;
6588-
6589- const totalBlocks = (typeof stats.total_block
s==='number') ? stats.total_blocks : 0;
6590-
6591- const height = (typeof status.height==='numbe
r') ? status.height : 0;
6592-
6593- const peers = (typeof status.peers==='number'
) ? status.peers : 0;
6594-
6595-
6596-

6991-
6992- try{
6993-
6994- const [p, pay] = await Promise.all([
6995-
6996: api('/api/pool/stats').catch(()=>null),
6997-
6998- api('/api/pool/payouts').catch(()=>null)
6999-
7000- ]);
7001-
7002- if(!p)return;
7003-
7004- $('pWorkers').textContent=p.workers?p.workers
.length:0;
7005-
7006- $('pShares').textContent=fmt(p.total_shares||
0);
7007-
7008- $('pBlocks').textContent=fmt(p.total_blocks||
0);
7009-
7010- $('pFee').textContent=(p.fee_percent||2)+'%';
7011-
7012- $('aBadge').textContent=p.auto_enabled?'ON':'
OFF';
7013-
7014- $('aBadge').className='badge '+(p.auto_enable
d?'on':'off');

7097-
7098-
7099-
7100-async function toggleAuto(){
7101-
7102: const p=await api('/api/pool/stats');
7103-
7104- const next=!p.auto_enabled;
7105-
7106- const r=await api('/api/pool/auto/config',{
7107-
7108- method:'POST',
7109-
7110- headers:{'Content-Type':'application/json'},
7111-
7112- body:JSON.stringify({enabled:next})
7113-
7114- });
7115-
7116- if(r.ok){toast('Auto-payout '+(next?'enabled':'
disabled'));vib(20);await refreshPool()}
7117-
7118- else toast('Failed');
7119-
7120-}

8268-
8269-
8270-
8271- // ============ POOL ENDPOINTS ==========

8272-
8273: server_.Post("/api/pool/register", [this]
(const httplib::Request& req,
8274-
8275-
httplib::Response& res) {
8276-
8277- auto gf = [&](const std::string& key)
-> std::string {
8278-
8279- auto pos = req.body.find(""" + k
ey + """);
8280-
8281- if (pos == std::string::npos) ret
urn "";
8282-
8283- auto colon = req.body.find(':', p
os);
8284-
8285- if (colon == std::string::npos) r
eturn "";
8286-
8287- auto start = req.body.find('"', c
olon);
8288-
8289- if (start == std::string::npos) r
eturn "";
8290-
8291- auto end = req.body.find('"', sta
rt + 1);

8340-
8341- });
8342-
8343-
8344-
8345: server_.Get("/api/pool/job", [this](const
httplib::Request& req,
8346- httpl
ib::Response& res) {
8347- std::string addr;
8348-
8349- auto it = req.params.find("address");
8350- if (it != req.params.end())
8351- addr = it->second;
8352-
8353- if (!addr.empty()) {
8354- const auto heartbeat_now =
8355- static_caststd::uint64_t(st
d::time(nullptr));
8356- std::lock_guardstd::mutex heart
beat_lock(g_pool_mutex);
8357- for (auto& entry : g_pool_workers
) {
8358- if (entry.second.address == a
ddr) {
8359- entry.second.last_seen =
heartbeat_now;
8360- break;
8361- }
8362- }
8363- }

8544- res.set_content(
8545- "{"ok":false,"error":"unable
to publish stable pool job"}",
8546- "application/json");
8547- });
8548-
8549: server_.Post("/api/pool/submit", [this](c
onst httplib::Request& req,
8550-
8551- h
ttplib::Response& res) {
8552-
8553- auto gs = [&](const std::string& key)
-> std::string {
8554-
8555- auto pos = req.body.find(""" + k
ey + """);
8556-
8557- if (pos == std::string::npos) ret
urn "";
8558-
8559- auto colon = req.body.find(':', p
os);
8560-
8561- if (colon == std::string::npos) r
eturn "";
8562-
8563- auto start = req.body.find('"', c
olon);
8564-
8565- if (start == std::string::npos) r
eturn "";
8566-
8567- auto end = req.body.find('"', sta
rt + 1);

8811-
8812- });
8813-
8814-
8815-
8816: server_.Get("/api/pool/stats", [this](con
st httplib::Request&,
8817-
8818- htt
plib::Response& res) {
8819-
8820- {
8821-
8822- const std::size_t current_height = no
de_.height();
8823- std::lock_guardstd::mutex lock(
g_pool_mutex);
8824-
8825- if (!g_pool_state_loaded.exchange
(true)) {
8826-
8827- pool_load_state_unlocked(wall
et_path_.parent_path() / "pool_state.txt");
8828-
8829- }
8830-
8831- std::ostringstream out;
8832-
8833- out << "{"ok":true"
8834-

9960- });
9961- window.CZR_XOF_APEX_JS_READY = true;
9962- setBadge('CZR JS OK | API CHECKING', '#a66b00')
;
9963-
9964- function checkCzrApi(){

===== 3. WORKER DATA STRUCTURE =====
75-namespace caesar {
76-
77-
78-
79:struct PoolWorkerInfo {
80-
81- std::string address;
82-
83- std::string worker_name;
84-
85- std::uint64_t shares = 0;
86-
87- std::uint64_t shares_pending = 0;
88-
89- std::uint64_t last_seen = 0;
90-
91-};

134-
135-inline std::mutex g_pool_mutex;
136-inline std::mutex g_pool_job_build_mutex;
137-
138:inline std::map<std::string, PoolWorkerInfo> g_poo
l_workers;
139-
140-inline PoolJobState g_pool_current_job;
141-
142:inline std::uint64_t g_pool_total_shares = 0;
143-
144-inline std::uint64_t g_pool_total_blocks = 0;
145-
146-inline std::uint64_t g_pool_job_counter = 0;
147-
148-inline double g_pool_fee_percent = 35.0;
149-
150-inline std::uint64_t g_pool_owner_share_accum = 0;
151-
152-inline std::vector g_pool_payout
s;
153-
154-

278- std::ofstream f(p, std::ios::trunc);
279-
280- if (!f) return;
281-
282: f << "total_shares=" << g_pool_total_shares <<
"\n";
283-
284- f << "total_blocks=" << g_pool_total_blocks <<
"\n";
285-
286- f << "job_counter=" << g_pool_job_counter << "
\n";
287-
288- f << "fee_percent=" << g_pool_fee_percent << "
\n";
289-
290- f << "auto_enabled=" << (g_pool_auto_enabled.l
oad() ? "1" : "0") << "\n";
291-
292- f << "auto_blocks=" << g_pool_auto_blocks.load
() << "\n";
293-
294- f << "last_payout_height=" << g_pool_last_payo
ut_height.load() << "\n";

320- f << "\n";
321-
322- }
323-
324: for (const auto& kv : g_pool_workers) {
325-
326- const auto& w = kv.second;
327-
328- f << "worker=" << w.address << "|" << w.wo
rker_name << "|"
329-
330- << w.shares << "|" << w.shares_pending <
< "|" << w.last_seen << "\n";
331-
332- }
333-
334- for (const auto& r : g_pool_payouts) {
335-
336- f << "payout=" << r.timestamp << "|" << r.
block_height << "|"

352- std::ifstream f(p);
353-
354- if (!f) return;
355-
356: g_pool_workers.clear();
357-
358- g_pool_payouts.clear();
359-
360- g_pool_users.clear();
361-
362- g_pool_all_users.clear();
363-
364- g_pool_next_user_number = 1;
365-
366- g_pool_total_registered = 0;
367-
368- auto split = [](const std::string& s, char d)
{

400- std::string val = line.substr(eq + 1);
401-
402- try {
403-
404: if (key == "total_shares") g_pool_tota
l_shares = std::stoull(val);
405-
406- else if (key == "total_blocks") g_pool
total_blocks = std::stoull(val);
407-
408- else if (key == "job_counter") g_pool

job_counter = std::stoull(val);
409-
410- else if (key == "fee_percent") g_pool_
fee_percent = std::stod(val);
411-
412- else if (key == "worker") {
413-
414- auto q = split(val, '|');
415-
416- if (q.size() >= 5) {

426- w.shares_pending = std::stoull
(q[3]);
427-
428- w.last_seen = std::stoull(q[4]
);
429-
430: g_pool_workers[w.address] = w;
431-
432- }
433-

SOURCE_MODIFIED=NO
WORKER_STOPPED=NO
SERVER_RESTART=NO
WALLET_DATA_TOUCHED=NO
CHAIN_DATA_TOUCHED=NO
~/caesar-czr-internal-real $

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions