Skip to main content

LWMA target calculator for dual-algo Avian forks (pybind11)

Project description

avian_lwma

High-performance LWMA (Zawy v3) target calculator for dual-algo Avian forks (X16RT + MinotaurX).

  • No Boost/OpenSSL: ships a tiny 256-bit integer core (GCC/Clang required for __uint128_t).
  • pybind11: import from Python and call at header-sync/checkpoint time.
  • Per-algo windows: pass the last N headers of a given algo.
  • Optional WASM FFI: compile the same core to .wasm if you want a web/Node verifier (not included in this zip).

Quick start (build wheel)

pip install -U pip build
pip install pybind11 scikit-build-core
pip install .

Windows: build with MSYS2/MinGW or Clang, or use WSL. (MSVC lacks __uint128_t; a MSVC-safe Big256 can be added.)

CMake build

cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build -j

Python usage

from avian_lwma import HeaderLite, next_bits_window, filter_last_n_for_algo

N = 45           # LWMA window
T = 30           # target spacing (seconds)
POW_LIMITS = {
    0: "00000fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",  # X16RT
    1: "000fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",  # MinotaurX
}

def algo_from_version(ver: int) -> int:
    return 1 if (ver & (1<<28)) else 0  # example mapping

# chain: list[HeaderLite] oldest->newest (fill from your header DB)
window = filter_last_n_for_algo(chain, N, algo_from_version, algo_id=1)
expected_bits = next_bits_window(window, T, len(window), POW_LIMITS[1])

API

  • HeaderLite(time: uint32, version: uint32, bits: uint32)
  • next_bits_window(window, target_spacing_s, N, pow_limit_hex) -> int (compact bits)
  • filter_last_n_for_algo(chain, N, algo_from_version, algo_id) -> list[HeaderLite]

Notes

  • Targets are full 256-bit integers decoded from compact bits. The result is clamped to pow_limit before re-encoding.
  • The Big256 here uses __uint128_t for intermediate math. For MSVC, swap in a different Big256 (PRs welcome).

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

avian_lwma-0.1.0.tar.gz (7.0 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

avian_lwma-0.1.0-cp312-cp312-win_amd64.whl (85.1 kB view details)

Uploaded CPython 3.12Windows x86-64

avian_lwma-0.1.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (90.3 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

avian_lwma-0.1.0-cp312-cp312-macosx_11_0_arm64.whl (75.8 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

avian_lwma-0.1.0-cp312-cp312-macosx_10_13_x86_64.whl (80.4 kB view details)

Uploaded CPython 3.12macOS 10.13+ x86-64

File details

Details for the file avian_lwma-0.1.0.tar.gz.

File metadata

  • Download URL: avian_lwma-0.1.0.tar.gz
  • Upload date:
  • Size: 7.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for avian_lwma-0.1.0.tar.gz
Algorithm Hash digest
SHA256 09347984b09e374016332173910a4effe0387f3664425a7790a6b6bcce673e74
MD5 162cdc0fd8ed86dc02a5ae7f08041adc
BLAKE2b-256 71e851737d96d0c1f13dd280c9d7bf6c0f528c0ffc3913e8aaf4c8743e8ec719

See more details on using hashes here.

File details

Details for the file avian_lwma-0.1.0-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: avian_lwma-0.1.0-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 85.1 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for avian_lwma-0.1.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 1b0c2e6414c787ae92688144fa63ff05b9f6888906f6d557017a2434f049e1be
MD5 9ab5ee32b0b4174298345de3000e7db0
BLAKE2b-256 9d887fedd8bbf0bb593a5556504e8499e73542fb5eb71adec731de0a248e23b4

See more details on using hashes here.

File details

Details for the file avian_lwma-0.1.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for avian_lwma-0.1.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 32937c0b6f34ff77cd9987dffa3ce491c4e3012a933463f2b496ff6c96edc4cf
MD5 1392b95c98c96eeee19d7f90c87f8623
BLAKE2b-256 7af68ccaa236c93884a50ddcf6d363e8b6924dfa2c6a2a48228b94391b34df6d

See more details on using hashes here.

File details

Details for the file avian_lwma-0.1.0-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for avian_lwma-0.1.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f48f1f6e88c8d3f23b49cba542ef1063f5a480a955b74587cb5307a0ea13b030
MD5 60d00d8f8dabbf98224bdef3bd1308e0
BLAKE2b-256 21030611ecc5ede80c5cfcf5865275f272831118af703b5ad6330c8c3c523716

See more details on using hashes here.

File details

Details for the file avian_lwma-0.1.0-cp312-cp312-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for avian_lwma-0.1.0-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 e6250057908dcbee66f5c1f37961a0a1ff0951939236840890ecbc211e20cc93
MD5 fa284bc531c4599b9f66da87908ee286
BLAKE2b-256 e51c8b55b15bce5c227ed488bd42441a0bd769cbc5eb2502e63233f8c4cb81d1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page