← Code & releases

Smoother difficulty — ending the 2-hour seesaw

Shipped in v0.26.1, together with Send To Many — both switch on at block 364,100. Confirmed in the code: TEXITcoin targets 3-minute blocks and recalculates difficulty only every 40 blocks, using only those 40. Luck alone makes a 40-block set look 15–20% fast or slow, and the chain then corrects fully for that luck. That's the seesaw the pool is seeing. The fix recalculates a little every block from the last 60 blocks (LWMA, used by many proof-of-work coins for this exact problem).

01

Side-by-side simulation

1,500 blocks (about 3 days) with the pool's real steady 19 TH/s and nothing else changing. Red is today's 40-block rule; blue is the new per-block rule. Real timestamps can't be replayed, because each block's timing depends on the difficulty it was mined at, so this replays the same luck through both rules.

Today (40-block)New (LWMA)
Difficulty low → high614,641 → 1,179,950571,511 → 1,080,224
Typical swing±15.1%±11.1%
Average block time3.08 min3.03 min
Gaps over 15 minutes1414

Some long gaps always remain. That part is pure luck in mining and no rule removes it. What goes away is long gaps bunching up after every high reset.

02

What the patch changes

Three files, 53 added lines, nothing removed:

  • src/pow.cpp: the new per-block calculation. From the switch-over block on it replaces the 40-block rule. Before that block the old code runs unchanged, so the existing chain checks exactly as it does today.
  • src/consensus/params.h: the switch-over height and the 60-block window.
  • src/chainparams.cpp: mainnet switch-over set to a placeholder (999,999,999), testnet from genesis, regtest from block 150.

No jump at the switch: the new rule starts from the difficulty of the previous 60 blocks. Each block's time is capped at 18 minutes, and a backwards timestamp counts as 1 second, so faked times can't swing difficulty.

03

Apply it on node-omni (with Send To Many)

On node-omni.texitcoin.org via EC2 Instance Connect. This puts it on top of the Send To Many branch so v0.26.0 carries both. Paste one block at a time:

cd ~/texitcoin
git checkout feature/send-to-many
wget -O ~/lwma-difficulty.patch "https://core.honest.money/patches/lwma-difficulty.patch?v=$(date +%s)"
patch -p1 --dry-run < ~/lwma-difficulty.patch

That should list three "patching file" lines and nothing about "FAILED". If so:

cd ~/texitcoin
patch -p1 < ~/lwma-difficulty.patch
git commit -am "pow: per-block LWMA difficulty (v0.26.0)"
make -j2
04

Prove it on regtest

Fresh private test chain, then 250 blocks (the new rule turns on at 150):

cd ~/texitcoin
./src/texitcoin-cli -regtest -datadir=$HOME/txc-regtest stop
sleep 5
rm -rf ~/txc-regtest/regtest
./src/texitcoind -regtest -datadir=$HOME/txc-regtest -daemon
sleep 5
CLI="./src/texitcoin-cli -regtest -datadir=$HOME/txc-regtest"
$CLI createwallet regtest
ADDR=$($CLI getnewaddress "lwma" "legacy")
$CLI generatetoaddress 250 "$ADDR" > /dev/null
for H in 140 149 150 151 160 200 250; do echo "block $H: $($CLI getblockheader $($CLI getblockhash $H) | grep '"bits"')"; done

Verified 3 October 2026 on node-omni: blocks 140 and 149 both show 207fffff — the old rule, untouched. From 150 on the number changes on every block: 2000b60b at 150, 2000b306 at 151, 200097dc at 160, 1f1ed73e at 200. It gets harder because regtest mines instantly, which is exactly what the new rule should do. On mainnet, blocks arrive at the real 3-minute pace, so difficulty follows the actual hashrate instead of fighting it.

The regtest node was restarted, so re-run the Send To Many test on the patch page too. Both features must work in the same build.

05

Rollout

  • Every TXC node must upgrade before the switch-over block. A node that doesn't will reject the new difficulty and split off.
  • The pool needs no changes: yiimp asks the node for the difficulty on every new block.
  • Pick the block only after the peer survey shows the network has upgraded, and announce it at least 2 weeks ahead.
  • ISK is built from the same code, so the same patch should apply. We will confirm that before choosing its own switch-over block.