Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/impl/btc/node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
#include <iomanip>
#include <random>

// Static members for DensePPLNSRing precomputed decay table
std::vector<uint64_t> btc::DensePPLNSRing::s_decay_table;
uint64_t btc::DensePPLNSRing::s_decay_per = 0;
bool btc::DensePPLNSRing::s_table_initialized = false;
// Static members for DensePPLNSWindow precomputed decay table
std::vector<uint64_t> btc::DensePPLNSWindow::s_decay_table;
uint64_t btc::DensePPLNSWindow::s_decay_per = 0;
bool btc::DensePPLNSWindow::s_table_initialized = false;

// Helper: read current RSS from /proc/self/status (Linux only)
static long get_rss_mb() {
Expand Down
8 changes: 4 additions & 4 deletions src/impl/btc/share_tracker.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ struct PPLNSEntry {
std::vector<unsigned char> script; // payout script (variable-length)
};

class DensePPLNSRing {
class DensePPLNSWindow {
public:
static constexpr uint64_t DECAY_PRECISION = 40;
static constexpr uint64_t DECAY_SCALE = uint64_t(1) << DECAY_PRECISION;
Expand Down Expand Up @@ -244,15 +244,15 @@ class DensePPLNSRing {
};

// ── Head-Level Incremental PPLNS ─────────────────────────────────────────
// Maintains a DensePPLNSRing + cached CumulativeWeights per active head.
// Maintains a DensePPLNSWindow + cached CumulativeWeights per active head.
// When verifying consecutive shares along a chain:
// 1. rebuild() at first share's parent: O(chain_len) — one hash map walk
// 2. extend() for each subsequent share: O(1) ring push + O(chain_len) dense recompute
// Total for N shares: O(chain_len + N × chain_len) sequential ops
// vs current: O(N × chain_len) random hash map ops — ~10x faster per op.

class HeadPPLNS {
DensePPLNSRing m_ring;
DensePPLNSWindow m_ring;
CumulativeWeights m_cached;
bool m_dirty{true};

Expand Down Expand Up @@ -306,7 +306,7 @@ class HeadPPLNS {

bool valid() const { return !m_ring.empty(); }
int32_t window_size() const { return m_ring.size(); }
const DensePPLNSRing& ring() const { return m_ring; }
const DensePPLNSWindow& ring() const { return m_ring; }
};

// --- ShareTracker ---
Expand Down
8 changes: 4 additions & 4 deletions src/impl/ltc/node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
#include <iomanip>
#include <random>

// Static members for DensePPLNSRing precomputed decay table
std::vector<uint64_t> ltc::DensePPLNSRing::s_decay_table;
uint64_t ltc::DensePPLNSRing::s_decay_per = 0;
bool ltc::DensePPLNSRing::s_table_initialized = false;
// Static members for DensePPLNSWindow precomputed decay table
std::vector<uint64_t> ltc::DensePPLNSWindow::s_decay_table;
uint64_t ltc::DensePPLNSWindow::s_decay_per = 0;
bool ltc::DensePPLNSWindow::s_table_initialized = false;

// Helper: read current RSS from /proc/self/status (Linux only)
static long get_rss_mb() {
Expand Down
8 changes: 4 additions & 4 deletions src/impl/ltc/share_tracker.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ struct PPLNSEntry {
std::vector<unsigned char> script; // payout script (variable-length)
};

class DensePPLNSRing {
class DensePPLNSWindow {
public:
static constexpr uint64_t DECAY_PRECISION = 40;
static constexpr uint64_t DECAY_SCALE = uint64_t(1) << DECAY_PRECISION;
Expand Down Expand Up @@ -244,15 +244,15 @@ class DensePPLNSRing {
};

// ── Head-Level Incremental PPLNS ─────────────────────────────────────────
// Maintains a DensePPLNSRing + cached CumulativeWeights per active head.
// Maintains a DensePPLNSWindow + cached CumulativeWeights per active head.
// When verifying consecutive shares along a chain:
// 1. rebuild() at first share's parent: O(chain_len) — one hash map walk
// 2. extend() for each subsequent share: O(1) ring push + O(chain_len) dense recompute
// Total for N shares: O(chain_len + N × chain_len) sequential ops
// vs current: O(N × chain_len) random hash map ops — ~10x faster per op.

class HeadPPLNS {
DensePPLNSRing m_ring;
DensePPLNSWindow m_ring;
CumulativeWeights m_cached;
bool m_dirty{true};

Expand Down Expand Up @@ -306,7 +306,7 @@ class HeadPPLNS {

bool valid() const { return !m_ring.empty(); }
int32_t window_size() const { return m_ring.size(); }
const DensePPLNSRing& ring() const { return m_ring; }
const DensePPLNSWindow& ring() const { return m_ring; }
};

// --- ShareTracker ---
Expand Down
Loading