# Changelog
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html)
## [Unreleased]
## [2.0.0] - 2026-11-25
This release brings the tokens of Bitcoin Cash (CashTokens,
`docs/cashtokens.md`): the store reads the tokens of every output, keeps the
token balance of every address and category, indexes each category, and
answers four new endpoints, counting the mempool. Outputs with tokens now
have their addresses, so the history and the balances of those addresses
are whole.
Before upgrading, take a copy of the database: the migration to version 24
cannot be undone, and on Bitcoin Cash it reads every block since May 2023,
which takes hours. Upgrade every store of a fleet together, since the
scripts of the shared pool take token entries. It needs haskoin-core 3.0,
haskoin-store-data 4.0 and haskoin-node 2.7. A store whose `--peer` nodes
whitelist it must now say what they grant (`--peer-permission`, or
`PEER_PERMISSIONS=mempool,noban` for `whitebind=mempool,noban@…`): without
`mempool` there, a Bitcoin store no longer asks them for their mempools.
### Added
- **The path of a transaction into the shared mempool is one machine,
specified and checked** (`docs/mempool-ingestion.md`,
`Haskoin.Store.Ingest`, run by `Haskoin.Store.Ingest.Run`). It replaces
five stages that each lost transactions in a way of their own: the queue
of announcements, the set of requests, the member's list of what waited,
its offers by turn, and the question to the peers at the start.
- Every transaction id has one place, and leaves it settled or given up
for a counted reason (`ingest.given_up.*`). A store that gave
something up reads the whole mempool of its **sources** again: the
RPC of its node (`--node-rpc`), and the peers whose node gives its
mempool when asked. It also reads them when
one connects, when the pool lost what it had, and every ten minutes.
So a loss is temporary, where it lasted until a block: a node
announces a transaction to a peer once.
- What a peer names is asked of the pool before anything is fetched, so
reading a mempool that the pool has costs the list of its ids.
- Each peer has a window of requests out, from 16 to 4,096, that grows
as the peer answers and halves when it does not, in place of asking a
node for its whole mempool at once.
- A transaction is offered when it arrives, each after those that it
spends from: a chain enters root first, in any order of arrival.
- What peers name while the store is a block behind is kept, and asked
for once it is in sync, where it was dropped.
The document says what the path guarantees and how each claim is
established: by construction, proved by Liquid Haskell for every state
(`proofs/`: that nothing leaves in silence, the bounds on memory, and
that every step ends, with where each id is kept in a module of its
own, `Haskoin.Store.Ingest.Ledger`),
checked through every order of events of small worlds by a model
checker in the test suite (`Haskoin.Store.Ingest.Model`,
`scripts/check-ingest.sh`), or tested against Bitcoin Core and Bitcoin
Cash Node in Podman (`Haskoin.Store.MempoolSpec`, and
`Haskoin.Store.NodeAxiomsSpec` for what is assumed of a node). A store
with no source, as one whose peers are all strangers on Bitcoin and
that has no RPC, says so in its log and in `/health`.
- **The RPC of the node is a source of that path** (`--node-rpc`,
`Haskoin.Store.NodeRpc`): the store reads the node's whole mempool
through it when it starts, whenever it may have missed a transaction,
when the pool lost what it had, and every ten minutes, as it does of a
peer that gives its mempool. So a store of Bitcoin Core that its node
does not whitelist no longer needs a block to get back what it missed.
To the machine the RPC is one more peer that is a source, asked within
a window that follows what the node delivers, so nothing of the machine
or of its proofs is particular to it. Before, the RPC was read only
after the pool had been emptied, 2,000 transactions every two seconds,
and a call that failed was taken for an empty mempool: a node that does
not answer now says nothing about what it has, and is tried again after
a second, then two, up to a minute.
- **`/health` says in words what it found.** Each check has a `text`,
such as "The database is 4 blocks behind the best header, at height
688,798, more than the 2 allowed: the store is syncing, or cannot import
blocks fast enough.", and the top a `text` for the whole store: that it is
healthy, with its height and peers, or what is wrong. They come from
haskoin-store-data 4.0 (`healthText`), so a client writes the same.
- **`/health` says how the store stands with the mempool of its nodes**,
in `mempool`: how many sources it has to read a whole mempool from
again, whether it may have missed transactions and has not read a
source since, and what is on its way to the pool. A store with no
source is healthy, and the `text` at the top says that what it misses
stays missed until a block.
- **The check of the database says more**: beside the state of writes, the
compactions and flushes running, the full tables in memory waiting for a
flush, the size of the files and of their live data, and the errors in
the background since the database opened, which say why writes are
slow. It is now a field of `HealthCheck` in haskoin-store-data
(`DatabaseHealth`), so the client reads it; the store added it to its
JSON outside the type before.
- **Tokens of Bitcoin Cash (CashTokens).** Outputs that hold tokens have
their addresses now, with haskoin-core 3.0, and so are in the history,
the balance and the unspent outputs of those addresses. Outputs, inputs
and unspent outputs have a `token` field on Bitcoin Cash. New endpoints:
`/address/{address}/tokens`, the token balances of an address, and
`/token/{category}/holders`, `/unspent` and `/transactions`
(`docs/cashtokens.md`). They count the mempool, as an address's balance
does: the fleet's pool in Redis keeps, for each category, its
transactions and outputs, and for each address and category the sums of
a token balance. Every store of a fleet must run this version, since
the pool's scripts take token entries.
- **Unix sockets for Redis, the node and its RPC.** `--redis-url
unix:PATH` reaches a Redis on a Unix socket; a peer written `unix:PATH`
is a Unix socket, with haskoin-node's peers on sockets; and
`--node-rpc-socket` sends the requests of `--node-rpc` through a Unix
socket, with the user and password of its URL. Neither node listens on a
socket itself, so it is something that joins one to the node, such as
socat. The courier of a published transaction gives such a peer the zero
address in its version message, where haskoin-core's `sockToHostAddress`
stopped on it.
- **The store asks what each peer's node allows.** With haskoin-node 2.7,
every peer runs a model of its node: the state machine of Bitcoin Core
32.1 or Bitcoin Cash Node 29.2.0 that haskoin-core translates from their
source. A message that the node would punish is not sent, and the log
says why, with the upstream line. When the pool fills again, the store
asks for the mempool only the peers whose node takes the request: one
that serves Bloom filters, as its version message says, or one that
whitelists the store with `mempool`. That replaces a rule of the store's
own, which asked every peer on Bitcoin Cash and only the `--peer` peers
on Bitcoin. That rule lost a Bitcoin Cash peer that served no Bloom
filters, and assumed that every `--peer` node whitelisted the store.
`--peer-permission` (`PEER_PERMISSIONS`) says what the nodes of `--peer`
grant, by the names of `-whitelist`.
- **The courier knows which nodes say when they refuse.** The model of the
node says whether it answers a refused transaction with a `reject`. A
`pong` with no `reject` before it now means that a Bitcoin Cash Node kept
the transaction (`Kept`), and still only that a Bitcoin Core node is done
with it (`Took`).
- **Documentation of the tokens.** The README has a section on the token
endpoints, with their answers and what each field means, one on how the
store keeps tokens, notes on upgrading to 2.0.0, and an example of the
Haskell client for tokens. `swagger.yaml` has an example answer of each
token endpoint, taken from a regtest chain.
### Changed
- The tests accept fast-logger 3.3 (`>= 3.2.9 && < 3.4`), as haskoin-node
2.7.0 does for
[stackage#8183](https://github.com/commercialhaskell/stackage/issues/8183).
The store logs through haskoin-node, whose suite passes with 3.3.0. The
store's own suite was not run with it: `stack.yaml` builds with 3.2.9.
- **The shared mempool is changed by decisions made in Haskell, each
carried out in Redis in one step or not at all**
(`Haskoin.Store.Fleet.Atomic`, `Haskoin.Store.Fleet.Pool.Decide`,
`docs/concurrency.md`). Its rules were a Lua script of eight hundred
lines, which had two faults. A script that fails after its first write
keeps what it wrote, so an error in it left the pool half changed, as
the output of value 0 did on 19 November; and the rules were kept
twice, in Lua to run and in Haskell to test against.
- A decision can only ask Redis questions and list writes, which its
type says. One small script that decides nothing asks the questions
again and carries out the writes only if every answer is the same;
otherwise it writes nothing and the decision is made again. An error
in a decision is an exception in Haskell before Redis is told
anything.
- The decisions are held to the script that they replace, which no
store runs any more: the two side by side in one Valkey, through
drawn sequences of offers, withdrawals, expiries and moves of the
tip, with all that Redis has compared after every step
(`Haskoin.Store.Fleet.DecideSpec`).
- **The store that moves the tip has the floor.** A move of the tip
over a block reads for a second or more, and a decision is carried
out only if nothing that it read has changed: with transactions
offered all the time it would lose every race. So while a store moves
the tip, an offer is late and is made again, and withdrawals,
expiries, and drops and evictions of the cache wait for the next
turn. A move costs in proportion to its block. A store whose move is
refused five turns in a row warns in its log, with how long the last
took and which answer of Redis had changed.
- **The floor lasts as long as the move.** The store says every two
seconds that it is at its move, in a key of its own (`fx:beat`), and
has the floor for ten seconds from each time. The floor lasted ten
seconds from when it was taken, and the move over a block of Bitcoin
took longer than that to decide on a server: it was refused at every
turn, the tip staying where it was while the database went on. A
decision also judges time by one clock, read at its start, where it
read the clock again each time it asked Redis, and so found its own
lease of ten seconds run out. A store says in its log when a move
took a second or more, since transactions wait meanwhile, and
where the time went: reading the blocks, reading and writing the
cache, deciding, the calls to Redis, carrying it out, and the
garbage collector.
- **`haskoin-store-bench decide`** times what the move of the tip over
a block costs to decide, without Redis: each pass over the decision,
its answers and writes, and what it allocates. Run it with
`+RTS -T -A64m`, as a store runs. The figures of this section were
measured without `-A64m`, where the collector goes over the model of
Redis three hundred times in a move: they compare one build with
another, and are more than twice what the move costs. With it the
move over 4,000 transactions is decided in 0.8 seconds.
- **The move of the tip is gone through once.** It names what it will
ask before it starts, in steps, where it found its questions as it
went and was gone through from its start for each step: five times
through a block in the benchmark, and more on a server. Deciding the
move over 4,000 transactions takes 1.3 seconds where it took 4.4,
on a desktop, and decides the same. What it asks of the transactions
of the pool that a block is in conflict with is named ahead too: on
a server, blocks with such transactions took nine and fifteen
seconds where the others took under five, and sixty of them made the
benchmark go from 1.1 seconds to 5.4; it is 1.2 with them named.
- **A store takes whatever its node has.** A transaction that a node
names is fetched and offered unless the pool has it. It was also left
alone if the fleet remembered having seen it, among the newest
100,000: a transaction that the pool had let go, for another that
took its place, and that the node took again later, stayed out of
the store for as long, through every reading of the node's mempool.
On a server one stayed out for hours. Two stores of a fleet whose
nodes hold transactions in conflict now each offer their own again
at every reading; the pool holds the one offered last. The set of
what the fleet saw (`fleet:seen`) is no longer kept: an offer writes
one thing less, and a member no longer trims it at each turn. The
key of an older store is left unread, and can be deleted.
- **A store asks its node for what a transaction spends from** when
the pool lacks it, at once. It waited for it to come by itself,
trying the transaction again after two seconds, four, eight, up to
twenty minutes, and a node names a transaction to a peer once: a
parent that a store had lost kept everything that spent from it out
of the pool until the next reading of the node's mempool. Bitcoin
Core sends a transaction that it never named to the peer; Bitcoin
Cash Node says that it has it not, and there the store waits as it
did. The rule is in the model of the path, with a check that a
machine without it fails, and Liquid Haskell passes.
- **A store that has the RPC of its node reads it again when it
connects to the node as a peer.** A node names to a peer nothing
that it took before the peer connected, and its RPC announces
nothing: what the node took between the reading of the RPC and the
connection was in neither, and stayed out of the store until the
next reading, ten minutes later. It lost four transactions in one
run of a test in about forty. A peer that connects and is no source
now makes the sources owe a reading. The model of the path has a
node with its RPC and a peer, and fails without the rule.
- **A Grafana dashboard for the store's metrics**, read from InfluxDB
as Telegraf's statsd input writes them, for a store that sends its
own statistics (`--statsd-aggregates --statsd-no-events`):
`tools/grafana/haskoin-store.json`, with the script that generates
it. Nine rows and 46 panels: requests, one kind of request,
overload, blocks and peers, the database, the path into the
mempool, the cache of xpubs and the runtime. Telegraf sums the
store's statistics up a second time, which leaves counts, sums and
the longest right, and means, rates and percentiles wrong: the
dashboard reads the first and works the rest out, and
`docs/grafana.md` says how. Checked on a real Telegraf and InfluxDB
with a known load, which `tools/grafana/check/run.sh` does again,
and not yet against a store in production. The README now lists the
metrics of the web server and of the reads of the database, which
the store sent and the README did not name, and what the statistics
of `--statsd-aggregates` are called.
- **A test of a store whose Valkey is emptied while it runs**, as by
`FLUSHALL`, against Bitcoin Core and Bitcoin Cash Node
(`valkeyFlush` in `Haskoin.Store.MempoolSpec`). Valkey goes on
answering, so nothing fails, and only the epoch tells the store that
the pool is gone. The store must say so once, and have the mempool
of its node again within fifteen seconds, without being started
again. A store also reads the mempool of its node by the clock,
which alone brought the pool back after 26 seconds in a store made
unable to notice: the test empties Valkey right after that reading,
so that only the noticing meets its limit. It fails for a store
that does not notice, and for one that notices and does not read
again. Tried once on servers too, under stores answering the
public, none of which was started again: Bitcoin Cash and the
testnets had the mempool of their node again in under three
seconds, and Bitcoin, with 65,962 transactions, in 233
(`docs/fleet-mempool.md`).
- **A store at the head of the chain is healthy, whatever the state of
its mempool.** `ok` of `/health`, and its status, no longer depend
on the two checks that look at transactions: `last-tx`, that one
came lately, and `pending-txs`, that few are asked for and not
received. A store that had every block was unhealthy, and taken out
of service, when its node went quiet or while it fetched a large
mempool. Both checks are still made and still say whether they
pass. `--tx-timeout` and `--max-pending-txs` set their limits as
before, and no longer decide anything.
- **A store takes no mempool transaction in until it has the
blocks.** While it takes its blocks, a store hears of new
transactions and cannot place one: what they spend is in blocks
that it has not yet. A store that took 160,000 blocks in half an
hour fetched what its node named meanwhile, held thousands, and
gave them up for seven minutes after it had its blocks, saying
`syncing` all that time. Until a store first has its blocks, the
path into the pool now keeps nothing that a peer names or sends
and asks for nothing; then it reads its sources. And a store first
has its blocks only once its node has the headers of its peers
(`chainHasHeaders`, of haskoin-node 2.7.0): the
database caught up with the last header again and again while the
headers came, two thousand at a time. A rule of the machine (`begun`), with a check
in the model and two planted bugs that it finds; that a transaction
sent unasked is not kept either is tested by an example and not
checked; tested against both nodes on
a chain of 2,500 blocks, with a test that failed before.
- **A store no longer shows the coinbase of a block that its node
took back.** A node publishes over ZeroMQ the ids of the
transactions of a block that stops being part of its chain, the
coinbase too, and gives that coinbase when asked, since it keeps
the block. A store with its node as a peer through the RPC and
ZeroMQ took it on the word of its node: an unconfirmed transaction
that could never confirm, until something emptied the pool. Two
were seen on each store of a testnet of a server, after a
reorganisation of two blocks. A coinbase is no longer taken in
when it arrives, whoever sent it: to the path into the pool, the
peer does not have it. And one that is not in the chain of the
store is never offered to the pool. Tested against both
nodes, with a test that failed before (`staleCoinbase`). One that
is in a pool already stays there until the pool is emptied.
- **`/health` says how the mempool stands, in one word**
(`mempool.sync`): `syncing`, `synced` or `unknown`. After a start,
or after Redis lost its data, a store has its blocks at once and
its mempool a minute later, on Bitcoin: it is healthy meanwhile and
shows fewer unconfirmed transactions than its node. A deploy that
waited for `/health` gave a store traffic 70 seconds before its
mempool was full: it can wait for `synced`.
- The mempool is measured against the nodes of the operator only.
It is `syncing` until each was asked for its mempool and had
twenty seconds to answer, the store has missed nothing of it
since, and the pool has decided on all that they named. A store
with no such node says `unknown`: what a stranger names is
nothing to measure a mempool against.
- It was a boolean, `filling`, for a few hours, measured against
every source. A store whose peers were all strangers said that it
was filling for ever: a transaction that it could not verify kept
its place for twenty minutes, and another came before it left.
- In the machine of the path as T9 of `docs/mempool-ingestion.md`:
three checks in the model, and five planted bugs that it finds.
That a store comes to say `synced` is tested and not checked,
also on both nodes while transactions come without a pause.
- Needs haskoin-store-data 4.0.0.
- **A source is read every minute at least**, where it was every ten
minutes. While transactions come it is read every thirty seconds,
as before.
- **A node as a peer, through its RPC and its ZeroMQ socket**
(`--node-rpc` with `--node-zmq`, `NODE_ZMQ`; `docs/node-peer.md`).
The peer-to-peer protocol is made for strangers: a node names what
it takes to a peer at its own pace, Bitcoin Core about fourteen a
second after a first batch, and in a burst a store was behind until
it next read the mempool, every thirty seconds. Somebody who runs
the node has its RPC, which answers anything, and its ZeroMQ
socket, which says what the node takes as it takes it.
- With both, the store has that node as one more peer
(`Haskoin.Store.NodePeer`): a pipe in memory, with a thread at
the other end that answers the messages of the peer-to-peer
protocol from the RPC (headers, blocks, transactions, the
mempool) and announces what the node publishes (`hashtx`,
`hashblock`, which both Bitcoin Core and Bitcoin Cash Node have).
Nothing else of the store changes: the node counts as a peer in
`/health`, it is a node of the operator, and it is a source.
- A store can run on it alone, with no `--peer` and no
`--discover`: discovery is no longer turned on for such a store.
- Both connections are the peer. If the RPC fails or the socket
closes, the peer is gone; a ping is answered only once the node
answered a call, so a node that hangs is a peer that is silent;
and the node is asked for its best block every thirty seconds, in
case the socket went quiet. When messages may have been lost, the
whole mempool is named.
- The store speaks the protocol of ZeroMQ itself (ZMTP 3.0,
`Haskoin.Store.NodeZmq`), with no library of the system. A Unix
socket works as an address (`ipc://PATH`).
- Tested against both nodes: the subscriber; a store with no other
peer that has 150 blocks, the mempool, what the node takes next
and its next block; the same store when its node hangs and goes
on; and on Bitcoin Core, 800 transactions that the node took in
seconds, there within five seconds of the last with no reading,
where the peer-to-peer protocol alone is late. Not tested: a
first sync of a real chain this way, which takes one RPC call for
each block.
- **The RPC alone makes the node a peer too** (`--node-rpc` without
`--node-zmq`). Nothing publishes then, so the peer asks the node
every five seconds: for its best block, and, while no other node
of the operator is a peer of the store, for the ids of its
mempool, of which it names those that are new. While every other
peer is a stranger, that keeps the store at most five seconds
behind a node that it trusts. Such a store runs with no
peer-to-peer connection as well, and discovery is not turned on
for it. Tested against both nodes (`polls`: three batches and a
block, each there within twelve seconds, which fails when the
peer asks every sixty). Not measured: what asking a mempool of
sixty thousand transactions every five seconds costs the node.
- **A store can run without ever connecting to a peer**, from no
chain at all: with the RPC of its node, and its ZeroMQ socket or
not. Tested on both nodes, each way, on a chain of more than
2,500 blocks, which is more than a node gives of headers in one
answer (`noPeerEver`). Not tested on a real chain.
- **A store that has the RPC and not the ZeroMQ socket warns of
it**: the two are expected together. In the log, when the store
starts and when the peer connects, and in `/health`, as a
sentence in the new `warnings` and in `text`. A warning decides
nothing: `ok` and the status stay as they are. It needs
haskoin-store-data 4.0.0.
- The web server no longer reads the RPC as a source of its own
(`nodeFeedLoop`): the node peer is that source.
- The node of `--node-rpc` is a node of the operator with
`--foreign-peers` too, which speaks of the nodes of `--peer`. It
was taken for a stranger.
- **The peers that the operator gave are kept** (`--peer`, and the
node of `--node-rpc`). They are the ones whose word the store takes,
and the only reason for one to have no connection is now that it
takes none. From haskoin-node's branch `sticky-peers`:
- never dropped for its age: `--max-peer-life` is for peers found by
discovery;
- tried again every ten seconds at most when its connection ends,
for ever, where it waited up to ten minutes;
- a slot kept for it while it is away: with `--discover`, peers
found on the network filled every slot meanwhile, and the node of
the operator found none when it came back.
Tested in haskoin-node, the first against both nodes. Not tested end
to end: a store with discovery whose own node is away.
- **A stranger is not taken at its word.** A store verifies no script:
it takes a transaction because a node took it. It did so of every
peer, and a peer found by discovery is anybody: it could send a
spend of somebody's coins with a signature that does not verify,
and the store showed it, as a payment that was never made or as
coins spent that were not. A test offers such a transaction as the
store offered every one: it is taken.
- The store now takes the nodes of `--peer`, and the node of
`--node-rpc`, for nodes of its operator, and takes their word as
before. `--foreign-peers` (`FOREIGN_PEERS`) says that the nodes
of `--peer` are not.
- What only strangers name is looked at before it is offered. If
every signature of a coin locked to one key verifies, it is
taken. If one does not, or it spends more than it has, or its
tokens come from nowhere, it is given up with all that spends
from it (`ingest.given_up.forged`). If it spends a coin locked by
a script, which only a full node can judge, it is held until a
node of the operator names it, twenty minutes at most, and not
shown meanwhile (`ingest.given_up.not_vouched`).
- So a store with a node of its operator among its peers misses
nothing, and one with only strangers shows a spend of a script
when a block confirms it.
- The checks are in haskoin-core (`Haskoin.Transaction.Judge`,
`judgeRelayed`), with those of `POST /transactions`, which moved
there from this package: they say nothing of a store, and other
programs can use them. Only what no node can take is refused: a
rule of relay is the node's own.
- The rule is in the machine of the path (T8 of
`docs/mempool-ingestion.md`), and the model has seven worlds for
it, 26 in all, with five planted bugs that it finds; its first
version had two of them. Liquid Haskell passes. Tested with real
signatures against a real pool, and against Bitcoin Core: a store
whose only peer is a stranger takes what the wallet of the node
signed and not what a script spends, and takes both once the peer
is a node of its operator.
- It builds on haskoin-core's branch `judge-transactions`.
- **A store of Bitcoin has a whole mempool again in a minute and a
half, where it took over three.** After each transaction that came,
the path into the pool said how many ids it knew, and counted them
by making a set of them all: 0.8 milliseconds for 65,000 on a
desktop, for each of 65,000 transactions. A store whose Redis had
lost its data, or that started on a new pool, took in 380
transactions a second with a core busy, its Redis idle and requests
out to its node all the time: 233 and 259 seconds on a server
answering the public, 191 on one answering nobody. The count is the
size of a map now, and the same store took in 2,300 a second and had
the 65,314 transactions of its node after 87 seconds, 294 a second
from the first seconds and over 1,000 from the second minute. What
remains is the offers, one at a time.
- **A store that is slow to fill its pool says where its time goes.**
Every ten seconds in which the path into the pool was busy for five
or more, it says in its log how many events, offers and questions to
the pool it went through, and how many milliseconds went to the
machine, to the offers, to the questions, to sending requests and to
saying its state, with the offers split into what each reads: whether
a block has the transaction, the outputs that it spends from the
database and from the pool, which of them are unspent, and the
pool's decision. Nothing outside the store could tell. That line is
what found the count above, after a cause reasoned from the shape of
a curve had been wrong.
- **A store that takes a whole mempool at once offers each
transaction to the pool once.** A transaction that spends from one
that the store is still fetching waits for it, and was offered to
the pool all the same two seconds later, then four, eight and so
on, in case that one had been given up. The pool could only refuse
it. A held transaction is now offered at its time only if one of
those that it waits for has no place any more, which is what the
time is for (`docs/mempool-ingestion.md`). Given 65,000
transactions in chains of 24 at once, with a millisecond for each
offer, the machine made 103,862 futile offers and took 169 seconds;
it makes none now, and takes the 65 seconds of the offers
(`Haskoin.Store.IngestSpec`, in three seconds). Against Bitcoin
Core with 24,000, a store with an empty pool made 44,000 futile
offers and had them all in 18 seconds; none and 13 seconds now. On a
server with 65,000 it changed nothing that could be measured: this
was not what made the store slow there. The model checks the rule
both ways, with a planted bug for each, and Liquid Haskell passes.
- **The tip moves at once, and the pool lets go of the block's
transactions after it.** A move of the tip over a full block took
what the block confirmed out of the pool in the same step: more than
a hundred thousand writes, for which the tip waited five to fifteen
seconds on a server, nearly one of them inside Redis, which answers
nobody else meanwhile, and more with every cached extended key. The
move now marks those transactions, one write for each, and they
leave afterwards, two hundred at a time. A request that would read
one of them takes it out first, so every answer is that of a pool
that has let go of everything; nothing enters the pool until it has.
In the benchmark the move over 4,000 transactions is decided in 0.12
seconds where it took 0.8, and 2.7 with a cached key at every
address. A move that undoes a block is as it was.
`scripts/check-pool.sh` checks the three rules in small worlds, with
the decisions themselves: every pool, every block and every order of
taking out (`docs/tip-first.md`). And no decision can write to the
pool or to the cache while a transaction is marked: every write to
one of their keys asks first, whatever the decision does for
itself. That taking transactions out leaves the same pool in any
order is proved by Liquid Haskell for the pool as a pure value
(`Haskoin.Store.Fleet.Pool.Order`).
- **A store reads the mempool of its node every thirty seconds while
transactions come**, and twice as long after each reading that
follows none, up to the ten minutes that it was. Bitcoin Core names
transactions to a peer at fourteen a second after a first batch, to
a peer that it whitelists too, so a store was minutes and thousands
of transactions behind its node whenever the node took more: nothing
was lost, and all of it was late. Asked for its mempool, the node
names everything at once. A store says in its log when going through
what a node named at once took a second or more.
- **`rbf` is true for every unconfirmed transaction on Bitcoin, and
false elsewhere.** The nodes of Bitcoin take a replacement of any
unconfirmed transaction, whatever it signals, since Bitcoin Core 28,
and Bitcoin Cash has no such rule. The field said whether a
transaction signalled replace-by-fee (BIP 125) or spent an
unconfirmed one that did, which the pool worked out for every
transaction and kept right as parents were confirmed and came back:
two sets in Redis, and questions about the children of every
transaction that a block confirmed. None of that is kept or asked
any more; the sets `pool:own` and `pool:rbf` of an older store are
left unread. The move over 4,000 transactions is decided in 1.1
seconds.
- **A decision of any size is carried out.** Its questions and writes
go to Redis a thousand to an argument, without the writes that a
later delete undoes and with one command for many members of a key.
They went as an argument for each word, 1,008,352 for the move of
the tip over one block of Bitcoin, and Redis closes the connection of
a command with more than 1,048,576.
- **It costs Redis more:** an offer that is taken is two calls where it
was one, and about 137 microseconds of Redis where the script took 74
(Valkey's own count). That leaves room for some seven thousand offers
a second.
- **Breaking for a fleet: keys start with `hs3:<network>:`**, where they
started with `hs2:`. Stores of this version and older ones on one
Redis are two fleets, each with its own pool. Upgrade every store of
a fleet together; the keys under `hs2:` can be deleted afterwards.
- **The cache of extended public keys is written the same way**
(`Haskoin.Store.Fleet.XPub.Decide`): building an entry, moving it
with the tip in pieces, dropping and evicting. A script that failed
among the thousands of rows of a build left an entry half written. A
build of a key with 20 addresses costs Redis about 1.5 milliseconds
where it cost 1.0. Its reads are still one script and one call, and
write nothing but the note that a key was used: a move of the tip
that its store left for ten seconds is no longer ended by a read, but
by the build that follows the miss.
- **That a decision sees its own writes rightly is proved** for what it
asks about one cell: a field of a hash, a member of a set, the score
of a member, what a key holds. What a write does to a cell is written
once (`Haskoin.Store.Fleet.Atomic.Cells`), for the model of Redis and
for the decision, and Liquid Haskell checks, for every list of
writes, that the cell in the model after them is what the decision
works out (`proofs/`). It assumes four facts of `Data.Map`. The rest
of what a decision can ask is tested, as before.
- **A write of the wrong kind to a key does not compile.** The script
that carries out a decision cannot fail half way unless Redis
refuses a command, which it does for a key of another kind and for an
addition to what is no number. A key now has its kind in its type
(`Haskoin.Store.Fleet.Atomic.Keys`), and the decisions are written
with questions and writes that each take keys of one kind.
The scripts of the reports and of the move of the tip without the pool
are as they were.
- **The testnet3 of Bitcoin Cash is `--net bchtest3`**, no longer
`bchtest`, as haskoin-core 3.0 renames it after `bchtest4`. Bitcoin Cash
Node still runs testnet3, and the store keeps it, as it keeps Bitcoin
testnet3 (`btctest`), which haskoin-core deprecates. The name is also
the store's data directory, its prefix in Redis, its StatsD namespace
and its `network` in the API: before upgrading a store of testnet3,
rename `DIR/bchtest` to `DIR/bchtest3`, and set `NET=bchtest3`. Its
shared mempool fills again under the new prefix. Addresses keep the
CashAddr prefix `bchtest`. `hsq -n bchtest3` follows.
- **The tests name no address or port, and use only real nodes in
Podman.** The tests of downloading that a mock peer served in memory
(`StoreSpec`) now sync from Bitcoin Cash Node in Podman
(`Haskoin.Store.DownloadSpec`): the blocks asked 64 at a time, every
transaction of a block as the node has it, a second node taking over from
one frozen with `SIGSTOP`, and a heap that stays flat over 5000 blocks.
The web servers of the integration tests listen on Unix sockets, which the
tests, the WebSocket client and the client of haskoin-store-data reach;
the price service is a name that never resolves, and the RPC that does
not answer is a socket that nothing listens on. The test of HTTPS makes
its certificate with openssl and its requests with curl in a container of
the test image, not with the programs of the machine. The mock peer of
the benchmark, and the peers of the tests of publishing, are named by
Unix sockets. The benchmark compiles again: it lacked the field
`nodeRpcSocket` of its web server, and now the permissions of its peer.
- **The test of tokens queries the four endpoints** through the client of
haskoin-store-data, with the transactions in the mempool and then
confirmed: the balance of the address, the holders, the unspent outputs
and the transactions of the category, and the amounts as strings in the
JSON.
- **A store that does not sync in the integration tests explains
itself.** The tests keep the last 400 lines of the log of each store,
whether they print it or not, and when a store does not reach the best
block of its node in time they print them, with what the node says of its
chain and of its peers and what the store says of its health and peers.
A store stopped short of its node a few times on Bitcoin Cash Node, too
seldom to be run again with its log.
- **The example of the client in the README compiles**: it needed
`OverloadedStrings` for the text of its address.
- **The integration tests run their containers through
[podman-test](https://github.com/jprupp/podman-test)**, in place of the
code of their own in `integration/`: each environment is a pod with
Valkey on a Unix socket and the node's RPC and peer-to-peer ports bridged
to sockets, and the store reaches all three through them, so the pod has
no network. The tests are skipped with `PODMAN_TEST_SKIP`, in place of
`HASKOIN_STORE_NO_PODMAN`. The Bitcoin Core node that does not whitelist the
store now gives it its mempool, and the store is told so: without it the
node closed the store's connection over the request, now and then during
a test. The test of
the Haskell client mines a block at each look until the client hears
one, where it mined one and waited: a client whose stream opened after
that block heard nothing.
- **Database version 24.** On Bitcoin Cash the migration from version 23
indexes the outputs that hold tokens since the upgrade of May 2023: hours,
once, and it carries on where it was if stopped. On Bitcoin it writes the
new version. Four new column families keep older stores out.
- The checks of a published transaction read the token prefix with
haskoin-core's parser.
- **Builds on haskoin-core 3.0**, which reads the token prefix and adds a
field to `Network`, with haskoin-node and haskoin-store-data 4.0 on it
too. Until they are on Hackage, `stack.yaml` pins commits of their
GitHub repositories. The Blockchain.info API gives the legacy addresses of the
Bitcoin Cash test networks with the prefixes of testnet4, which are
those of testnet3, now that haskoin-core marks testnet3 as deprecated.
- **Releasing and formatting moved to
[jprupp/tools](https://github.com/jprupp/tools)**, shared by the Haskell
packages of this family. `haskell-release` builds and tests the package,
builds the source and documentation archives, then tags the commit,
pushes the tag and uploads both to Hackage. It leaves out the
documentation of the internal library `integration`, whose file
`haskoin-store:integration.txt` made Hackage refuse the archive, so a
release needs no step by hand. `haskell-format` replaces `scripts/format`.
- **CI runs through the workflow that the packages share** in jprupp/tools,
which also keeps the cache of the Nix build per release of nixpkgs.
`check-stack-paths` from there replaces `scripts/check-local-deps.sh`.
- **`haskell-dev`, from jprupp/tools, is the fast loop of work on the
code**: `build`, `test` and `docs`, without optimisation and with the
tests in eight processes, about 75 seconds in place of four minutes. The
five environments of `Haskoin.Store.IntegrationSpec`, each a node, a
Valkey and a store in Podman, are now groups at the top of the module, and
`haskell-dev.toml` names it, so that they run at the same time.
### Fixed
- **Races found by an audit of every protocol that runs at once**
(`docs/concurrency.md`, new, has each protocol, its machine, its owner,
the invariants and what changed):
- a peer passed over during a stall was disconnected for a block it was
asked for once another brought the store in sync (`Sync.finish`);
- the refill ran the block store's in-sync check on the web thread; it
goes through the mailbox now;
- a peer could owe a block twice; a block of a branch the node had left
could be imported; a revert published no best block;
- two threads pruning views could let go of the newest block's view;
- a store that was not live could empty the fleet's pool while one other
store was live; a store emptied it where the documentation said it
waits (`Unreadable`); a transaction in conflict could be lost for the
fleet; expiry could withdraw a transaction that had just come back;
- a request interrupted while it took the lock of an xpub left the job
reserved for good; the listener of builds spun while Redis was down,
grew without bound and woke requests for builds that never happened;
- one slow answer from Redis made every store answer 503; background
loops could die in silence; an error skipped the asking of published
transactions;
- announcements of transactions held up blocks on the block store's
thread; the transactions waiting to be offered had no bound.
- **New transactions and blocks show at once again.** Since the pool moved
to Redis, a transaction from a peer waited for the member's next turn,
up to two seconds, before it was in the pool and listed; it is offered
as soon as it comes now (`Haskoin.Store.Ingest`). A store that a block
made well, as after a sync, took no turn for up to two seconds either:
the block woke the member before the health check had run, and the
member slept until its timer. It now takes a turn as soon as the store
is well (`Haskoin.Store.Fleet.turn`). Measured in a downstream regtest
suite: 1.3 to 2.0 seconds for a transaction against 0.3 to 0.4 on
1.12.1, and 2.0 seconds for 101 blocks after a start against 0.01.
- **A store no longer falls behind the mempool of its node.** On a server,
a Bitcoin store fell 17,000 transactions behind its node: chains of 24
transactions that the node took in one second were offered child first
and took 23 rounds; announcements were dropped from a full queue, or
while the store was a block behind; and nothing asked the node again
for what was missed. The path into the pool is a new machine (see
Added).
- **A Bitcoin Cash Node with `--node-rpc` no longer waits half a minute
when it stops.** The store kept its RPC connection open, and the node
waited until it had been idle for `-rpcservertimeout`. Every RPC request
closes its connection now.
## [1.16.7] - 2026-11-20
### Fixed
- **A Bitcoin store no longer loses its peers when the pool fills again.**
A refill asked every connected peer for its mempool, and Bitcoin Core
disconnects a peer that asks unless it whitelists it: on groot the btc
store lost its three peers at once and answered 503 for seven seconds.
On Bitcoin only the peers given with `--peer` are asked now, since an
operator whitelists those; on Bitcoin Cash every peer still is, since
Bitcoin Cash Node answers anyone.
## [1.16.6] - 2026-11-19
### Fixed
- **The pool no longer stops at a transaction that pays an output of value
0.** Taking such an output out of an address's summary added `-0`, which
Redis does not read as an integer. The script failed at every turn of the
fleet, and the pool took in nothing more until the next restart of the
pool. Pay-to-anchor outputs, which Bitcoin Core relays since version 29,
have value 0. Since Redis keeps what a failed script wrote before its
error, the summaries of the addresses that the stuck turn touched could
drift; emptying the pool clears them.
- **A store no longer keeps every transaction it ever offered in memory.**
The fleet member kept a set of what it had offered to the pool, emptied
only when the pool was started again or Redis lost its data: about half
a million transactions a day on Bitcoin. It also made the store refuse,
silently, a transaction that left the pool and was sent again, such as
one that a replacement pushed out. The set is gone: the fleet's seen set
in Redis already keeps stores from fetching what the pool decided on.
- **Orphans no longer stop the store from offering transactions.** A
transaction whose parent never came waited in memory for ever, and a
round offers the 2,000 oldest that wait: once that many orphans had piled
up, nothing else was offered. An orphan is now let go 20 minutes after
the store heard of it, as Bitcoin Core does.
- **A restart of the pool no longer drops what the store was about to
offer.**
- **A restart of the pool fills it again.** After a reorganisation deeper
than 50 blocks, the pool was emptied and its transactions came back only
in a block, since the fleet had seen them and no store fetched them
again. The restart now empties the seen set too, and every store reads
its node's mempool over RPC (`--node-rpc`) and asks its peers for theirs,
as after a loss of Redis.
- **A store no longer loses its Bitcoin Core peers after Redis loses its
data.** From the first refill on, the store asked every peer that
connected for its mempool. Bitcoin Core disconnects a peer that asks
unless it whitelists it or serves bloom filters, which it does not by
default; so the store lost its public Core peers one after the other.
It now asks only the peers connected at the refill, once.
- **README: memory for indexes and filters.** They come to about 0.9% of the
database (16 GB for Bitcoin, 4 GB for Bitcoin Cash, measured on
api.haskoin.com), not 0.34%; and they, Bloom filters included, are held
outside the block cache, not in it. The `--block-cache-mb` help said the
same wrong thing and is fixed too.
- **Documentation brought up to date with Redis being required.** The
package description, the README's Docker quick start (it started the
store without Redis, which cannot work), the help of `/health` in
`swagger.yaml` (the `redis` and `database` fields are always there; a
store without Redis answers 503), and comments throughout the code that
still described an optional Redis, a store's own mempool, the token
design or functions that no longer exist.
- **`swagger.yaml`**: version 1.16.5; `request-too-large` (413) is sent;
the health check runs every second and at each block, not every 30
seconds; the 202 body of `POST /transactions` has a `message`.
- **README**: `nocache` is accepted and ignored on xpub routes; `stack.yaml`
may pin git commits; the integration image is under `integration/`; the
code map lists every module; links point at the document that has what
they promise.
- **Messages about pending transactions** (the `/health` log, the help of
`--max-pending-txs`, the reference): they count transactions requested
from peers and not received yet, not transactions waiting to be imported.
The log line of the migration from version 20 says the transactions were
taken out of the chain, not moved.
### Removed
- **The stress test of the cache** (`stress/`, `scripts/stress-cache.sh`,
`scripts/stress-report.py`, the `haskoin-store-stress` benchmark, and
wrk in the test image). It no longer ran against the current server and
measured a cache that no longer exists. `scripts/heap-profile-summary.py`
stays; the README says how to use it on its own.
- **The StatsD gauge `store.queued_txs`**: it counted transactions waiting
to be imported, which the block store no longer holds, and was always 0.
- **Dead code**: what the block store kept of transactions received from
peers, which nothing put there (`Haskoin.Store.BlockStore.Pending` now
holds only the requests); `insertReplaced`; `BlockStoreConfig`'s
`mempoolTimeout`; and unused fields of the fleet member.
### Changed
- **`hsq --help` fits the terminal.** The usage text is laid out for the
terminal's width (at most 100 columns): prose reflows, the command and
option lists stay aligned when there is room and stack when there is
not, and examples and the sample configuration are kept as written.
## [1.16.5] - 2026-11-19
### Added
- **`hsq`, a command-line client for people** (`tools/hsq/hsq`, Python,
standard library only): a coloured summary of `/health`, refreshed with
`-w`, and any API path as laid-out JSON, over a Unix socket, HTTP or
HTTPS, with a configuration per network. `docs/hsq.md` explains it. It is
not part of the Haskell package.
### Changed
- **Clear messages when the store cannot start.** A new module,
`Haskoin.Store.Startup`, turns each usual failure into one line that
says what is wrong and what to do, printed without a backtrace, with
exit status 1: no Redis or Valkey listening, an unknown Redis host, a
Redis that wants a password or another one (it used to start and answer
503 to everything), a URL that is not Redis's, a data directory that
cannot be made, a database held by another store, a port in use or below
1024, a host that is not this machine's, a Unix socket in use, missing
HTTPS files, and an unknown `--net`. Redis is now connected first, before
the database opens, and with a timeout of five seconds.
- **The warning when Redis stops answering gives the reason**, and says
that the store answers 503 until Redis is back (it said, wrongly, that
the store answered from the database).
- **"Not synchronized with the network"**: the message of the 503 that a
store answers without the block to answer from, with haskoin-store-data
3.0.1, which it now requires. The code stays `behind-fleet`.
## [1.16.4] - 2026-11-18
### Fixed
- **A reorganisation no longer loses the transactions of the abandoned
blocks.** A store alone in its fleet that reverted a block between its
report and its move of the fleet tip found the reported block off its
main chain, took that as a way it did not know, and moved the tip with an
emptied pool. The transactions of the abandoned blocks that no node had
any more were lost, and answered 404. Such a store now leaves the tip for
its next turn (`Unsettled` in `Haskoin.Store.Fleet.Member`). The
transactions still come back only in the commit that moves the tip, so
none is ever both confirmed at the tip and in the pool. This was the
intermittent failure of the integration test "sends again a payment that
the nodes forgot and the store lists"; a test of the fleet's cache now
makes the race happen every time.
## [1.16.3] - 2026-11-18
### Added
- **The API can listen on a Unix socket.** `--socket PATH` (`SOCKET`) makes
one, with the mode of `--socket-mode` (`SOCKET_MODE`, `0660` by default),
removes a stale one at start and refuses a path in use. A socket passed
by systemd socket activation (`LISTEN_FDS`) wins over both and over
`--host` and `--port`. The new `Haskoin.Store.Web.Listen` has both. The
access log shows `unix` for a client on such a socket.
## [1.16.2] - 2026-11-18
### Changed
- **RocksDB gets a background job a core**, from 2 to 16, instead of its
default of two. `--background-jobs` (`BACKGROUND_JOBS`) still overrides it,
and 0 still means RocksDB's default. A fresh sync of Bitcoin Cash froze at
height 436,814 because compactions fell behind and RocksDB stopped writes.
`max_subcompactions` stays at 1: `rocksdb-haskell-jprupp` 2.8.0 cannot set
it.
### Added
- **Write stalls are visible.** The new `Haskoin.Store.Database.Stalls`
polls RocksDB every five seconds and logs a warning when it delays or stops
writes, with the bytes of compaction pending, and a line when they recover.
`/health` reports it under `"database"`; stopped writes make the store
unhealthy, delayed ones do not. StatsD gauges `db.pending_compaction_bytes`
and `db.write_delayed`.
## [1.16.1] - 2026-11-18
### Changed
- **The stall follows the syncing peer's pace.** A peer is passed over when
it has sent nothing for four of its recent gaps between blocks, at least
two seconds, instead of always `--block-stall` seconds, which is now the
longest stall. A store that imports hundreds of small blocks a second
waited ten seconds on a peer that had gone quiet; it now waits two. The
pure rules are in `Haskoin.Store.BlockStore.Sync` (`patience`,
`stallFloor`, `stallFactor`, and the new `gap` of `Sync`).
### Fixed
- **Header sync no longer stalls block sync.** haskoin-node waited for the
chain to import each batch of 2,000 headers before it passed on any other
peer message, and on Bitcoin Cash a batch took 20 seconds. Blocks and pongs
waited behind it, and the store passed over peers that were delivering.
haskoin-node 2.6.1 no longer waits, and haskoin-core 2.0.1 connects Bitcoin
Cash headers about 60 times as fast. Both are unreleased and pinned by
commit.
## [1.16.0] - 2026-11-18
This release has one design (`docs/one-fleet.md`): Redis is required, every
store is a member of a fleet, the mempool is only in Redis, and every xpub is
answered from the fleet's cache.
### Added
- **Gauges of the latest block's import times** (`store.last_block_ms` and one per stage), which
keep their value until the next block, so that charts show the right time at any zoom.
- **Admission control that adapts** (`Haskoin.Store.Web.Admission`,
`Haskoin.Store.Web.Congestion`, `docs/congestion-control.md`). Only so many
long requests (lists, whole blocks, xpubs) run at once, so that a busy store
still answers its quick requests at once.
- **The limit follows the cores.** A probe on each capability waits on an
eventfd that a system thread rings every 10 ms, and measures how late a
woken thread runs, less GHC's collector pauses. Every half second the
controller cuts the limit by a quarter when that delay is over
`--target-delay` (25 ms) and the cores are used at 90%, at most once a
round trip (the smoothed time a request holds its slot). The delay
alone does not cut: requests that wait for a slow disk make it jump
while the cores have room. It grows along TCP CUBIC's curve, back toward
the level of the last cut and then past it, while the delay is under the
target, every slot was used and the cores, smoothed over two seconds,
are used under 90%. The limit stays between `--min-requests` (two a
core) and `--max-requests` (sixteen a core; 0 turns it all off).
- **The line in front is managed by CoDel** (100 ms interval, 5 ms target;
while overloaded, a request that waited past 10 ms is refused). It holds
up to `--request-queue` (64) requests for up to `--request-wait` (1 s).
It refuses nothing while the limit is free to rise (the cores under 90%,
the limit under its ceiling): such a line waits for the limit to catch
up, and refusing it cost clients that ask one after the other a second
of `Retry-After` each. A refused request gets 429 `server-busy`
with `Retry-After: 1`, which
clients and nginx take as "come back later"; a load generator retried
503s at once. A request in line sets no GHC timer: a sweep enforces the
waits.
- **A request for an xpub gives its slot back while it waits for the
indexer** (`Admission.admittedAside`, `aside`), and takes one again
without the line. The indexer bounds that work; holding the slot left
plain requests waiting a second behind cold xpubs.
- **Options:** `--max-requests` (`MAX_REQUESTS`), `--min-requests`
(`MIN_REQUESTS`), `--target-delay` (`TARGET_DELAY`), `--request-queue`
(`REQUEST_QUEUE`) and `--request-wait` (`REQUEST_WAIT`).
- **Metrics:** `web.cap.limit`, `web.cap.delay_us`, `web.cap.lateness_us`,
`web.cap.overloaded`, `web.cap.used`, `web.cap.round_trip_us`,
`web.cap.sojourn`, `web.cap.refused_full`,
`web.cap.refused_waited`, `web.cap.refused_codel`, `web.requests_waiting`,
and for each long route `web.cap.<route>.running`, `.waited`, `.held` and
`.refused`.
- **`haskoin-store-bench admission`** compares no limit, a fixed limit and
the adaptive one (`bench/Admission.hs`).
- **Xpubs are indexed once, in the background** (`docs/xpub-indexing.md`).
- **`Haskoin.Store.XPub.Indexer`**: threads that read xpubs into the
fleet's cache, one a core by default. Jobs that requests asked for go
before upkeep, and no xpub is queued twice; a request for an xpub that is
queued or running joins its job. A sweeper thread refuses the requests
whose time is up, so no GHC timer is set.
- **`Haskoin.Store.XPub.Lock`**: the lock of an xpub in Redis
(`<prefix>idx:<id>`), so that one store of the fleet indexes it. Its value
says which store holds it and when that store expects to be done, by the
clock of Redis.
- **`Haskoin.Store.XPub.Service`**: the one door to the cache for the web
server. `xpubAsk` says what to do on a miss and gives an `Answer`;
`xpubDelete` takes an xpub out.
- **`Haskoin.Store.XPub`**: what the door, the indexer and the web server
share, `XPubReads` and the `Budget` of a job. Every job gets `noBudget`;
the type stays as the seam through which a job settles and tells its size.
- **`StoreConfig.xpubs`** (`XPubConfig`, `defaultXPubConfig`) and the
options `--xpub-workers` (`XPUB_WORKERS`, 0 for one a core), `--xpub-wait`
(`XPUB_WAIT`, 10 seconds), `--xpub-horizon` (`XPUB_HORIZON`, 30 seconds)
and `--xpub-queue` (`XPUB_QUEUE`, 1000).
- **`web.reruns`** counts the requests answered again because an xpub that
they read changed meanwhile.
- **Timings of the stages of a block import**, for StatsD: `store.block_prepare`,
`store.block_prefetch`, `store.block_apply` and `store.block_write`, and the
read ahead by kind of key, `store.block_read_unspents`,
`store.block_read_spenders` and `store.block_read_balances` (both zero now).
They say whether a slow block is the disk, RocksDB's cache or the CPU.
- **`haskoin-store-bench import`** times the import of four kinds of full
block on a database of a million unspent outputs, and prints the stages and
the size of the batch (`bench/Import.hs`, `docs/block-import.md`).
**`haskoin-store-bench merge`** times reads of balances and spenders over
merge records that RocksDB has not compacted yet (`bench/Merge.hs`).
- **`--background-jobs`** (`BACKGROUND_JOBS`): how many threads RocksDB may
use for flushes and compactions, RocksDB's default unless set. More of them
shorten a backlog of compactions when the disk and cores have room.
`StoreConfig` has `backgroundJobs`. Needs `rocksdb-haskell-jprupp` 2.8.0.
- **In the library:**
- `Haskoin.Store.Database.Writer`: `runWriterReport` gives a `BatchReport`
with the `BlockTimes` of a block and the size of its batch; the
`readAhead` functions fill a batch's read cache with multi-gets on all
cores; `mergeBalance` and `mergeSpender` change a balance or a group of
spenders without reading it; `withoutReadCache` reads the database every
time.
- `Haskoin.Store.Logic.prepareBlock` gives the hashes, addresses and sizes
of a block.
- `Haskoin.Store.Database.Table`: the hash tables of a batch, keyed by the
hash that each key already holds.
- `Haskoin.Store.Database.Merge`: the merge operators of the balances and
the spenders.
- `Haskoin.Store.Database.Migrate`: `recordsVersion`, and a `MigrationError`
that says in words what is wrong with a version.
- `Haskoin.Store.Database.Reader` exports `withReader`,
`columnFamilyConfig`, `layeredFamilyConfig` and `mergeGuardFamily`, for
tests and benchmarks that open a database with other settings.
- `Haskoin.Store.Common.sortTxsWith` takes the hashes of the transactions
from a caller that has them.
- `Haskoin.Store.Exception`: `catchAny`, `handleAny` and `tryAny` catch any
error but not what stops a thread from outside; `bracket`, `bracket_`,
`finally` and `onException` run a cleanup that cannot be interrupted.
- `Haskoin.Store.Integration.Temp`, in the `integration` library: temporary
directories for the tests, the benchmark and the stress test.
### Changed
- **The fleet remembers what it saw, in Redis** (`fleet:seen`): the last
100,000 transactions that the pool decided on, taken, refused as a
conflict or let go unconfirmed, marked by the pool's script in the same
step. No store fetches them again when a peer announces them, after a
restart either; what a store holds unoffered it does not fetch again from
its own peers. Each store kept its own set in memory before.
- **Indexes and filters stay in memory** with their open table files, outside
the block cache, so data blocks can no longer evict them (about 0.34% of the
database).
- **Redis is required, and every store is a member of a fleet**, even a
fleet of one (`docs/one-fleet.md`). Without Redis, or behind the fleet tip,
a store is unhealthy: `/health` answers 503, where it was 203 without Redis.
- **The mempool is only in Redis.** A store hands the transactions that its
peers send to the pool and keeps no mempool of its own; RocksDB holds the
chain alone. A reverted block's transactions leave RocksDB, and the tip move
gives them back to the pool. `Haskoin.Store.Logic.Layered` is now
`Haskoin.Store.Logic`, which imports and reverts blocks, and `Query.Pooled`
has `chainRead` in place of `databaseRead`.
- **Migration:** a database of version 18, 19 or 20 has its unconfirmed
transactions taken out of the chain's indices, and the pool gets them again
from the peers. Nothing is written to the old mempool column families.
- **The tip move and the xpub cache are one Redis commit.** The member that
moves the fleet tip writes the cache's part in pieces, marking the entries
it touches (`cacheBegin`, `cachePieces`); one script then moves the pool,
the fleet tip and the cache tip and stamps the entries (`fleetCommit`). A
read of a marked entry waits up to two seconds, then has its request
answered again.
- **A reorganisation never empties the cache.** It is undone address by
address from the views at recent blocks (`tipMoves`). A store without a view
of the old tip does not move the tip; only a restart of the pool empties the
cache.
- **The pool fills again after Redis loses its data.** An epoch key
(`fleet:epoch`) tells the stores; each asks its peers for their mempools
again and, with `--node-rpc`, reads its node's, 2,000 transactions every two
seconds. Xpub entries are built again on demand.
- **Fewer round trips to Redis.** The fleet's Lua scripts are loaded once and
called by digest (`EVALSHA`), loaded again after `NOSCRIPT`. A request that
reads nothing of the pool, such as `/block/best`, reuses a tip seen in the
last 5 ms.
- **Every answer about an xpub comes from the fleet's cache**, never from the
database. The routes `/xpub/{xpub}` (with `balances`, `transactions`,
`transactions/full` and `unspent`) and the Blockchain.info routes
`multiaddr`, `rawaddr`, `unspent`, `balance` and `export-history` read the
cache, and on a miss wait for the one job that indexes the xpub. One store
of the fleet builds each entry, holding its dibs in Redis with its
estimate; the others wait for the commit, which Redis announces. Visible to
clients:
- a request that would wait longer than `--xpub-wait` (now ten seconds,
from five) gets 429 `server-busy` with a `Retry-After` from the one
estimate in Redis, the same on every store. The estimate of a running job
comes from its size (`Budget.sized`) and the recent time per
transaction. The job goes on unless the xpub is beyond `--xpub-horizon`
or the queue is full. A request for several xpubs is refused with the
longest wait;
- a failed job, or an xpub evicted before the request read it twice, gives
503 with `Retry-After: 1`;
- every xpub is cached after its first query, small ones included;
- `swagger.yaml` has the 429 and 503 on each of these routes.
- **A request reads one version of each xpub, never parts of two.** Every
commit gives an entry a new version, and a read gives the version in the
same script. A request that finds another version later is answered again
from the start, before anything was sent (`web.reruns`). Responses built
from transaction bodies take each transaction's confirmation and each
output's spender from the entry at that version, read with the bodies in
one round trip.
- **Lookahead addresses.** An entry holds a gap's worth of unused addresses
after each chain's window, so a payment to a wallet's next address is in
its entry as soon as the pool takes it.
- **Redis evicts xpubs by GreedyDual**, keeping longest those that would
cost most to index again (`Haskoin.Store.XPub.greedyLua`). Entries record
their cost in `fx:e:<id>:meta`, and `fx:prio` and `fx:level` replace
`fx:lru`. `cachedEntry` of `Haskoin.Store.Fleet.XPub` takes whether the read
is a use, and `cacheBuild` takes no time.
- **The filters of `/events`** ask the indexer for an xpub that the cache does
not have, as the routes do. A refusal answers the stream or the opening of
a websocket with 429 or 503, and closes an open websocket with 1013.
- **Options that no longer choose anything are gone:** `--redis` (`REDIS`),
`--fleet` (`FLEET`), `--no-xpub` (`NO_XPUB`), `--no-mempool`
(`NO_MEMPOOL`), `--sync-mempool` (`SYNC_MEMPOOL`), `--wipe-mempool`
(`WIPE_MEMPOOL`), `--redis-min-addrs` and `--redis-min-txs`
(`REDIS_MIN_ADDRS`, `REDIS_MIN_TXS`). `--redis-url` defaults to
`redis://localhost:6379`. `--redis-max-xpubs` only sets the size of the
cache, and the store refuses to start below 1. `nocache` is accepted from
older clients and ignored.
- **Removed from the library:** the database mempool and its copy in memory
(`Haskoin.Store.Database.Mempool`, `Haskoin.Store.Database.Copy`), the
layered queries (`Haskoin.Store.Database.Query.Layered`), the Redis cache
of a store alone (`Haskoin.Store.Cache`), `runWriterMempool`,
`MempoolChanges`, `importBlockSequential`, `newMempoolTx`,
`deleteUnconfirmedTx`, and the metrics `store.mempool` and
`store.block_read_mempool`.
- **A block is imported in stages, several times faster.** A full block took
a store of mainnet 13 to 18 seconds, with its disk and half its cores idle.
Now the hashes, addresses and sizes are worked out once on all cores; every
key the import needs is read ahead with multi-gets into the batch's cache,
each key once; the rules run in memory; and the batch is serialised on all
cores and written in one write. The database that comes out is the same,
byte for byte, as the tests check against the import of 1.15.1.
- **The batch of a block is handed to RocksDB packed**, 256 KiB a call
(`writePacked` of `rocksdb-haskell-jprupp` 2.8.0): some forty foreign calls
for a block where there were 65,000. It is still one atomic write.
- **A mined block is not validated.** A block that passed proof of work is
taken to have valid transactions, so the import reads only what it needs to
write the block: no spender of the chain, and no output that the block
itself makes. Only a coinbase is looked up in case it is confirmed already,
as two of 2010 are. A block that is not valid is written whole or not at
all; one that spends an output a block has spent is refused as an orphan.
- **Database version 23: a block changes balances and spenders without
reading them.** It writes how they change as RocksDB merge records, which
two merge operators that come with the store work out on reads and
compactions (`Haskoin.Store.Database.Merge`, `cbits/haskoin_store_merge.c`).
- **Upgrading from version 22 is one write**, made when the store first
opens the database.
- **There is no way back.** An older haskoin-store fails to open the
database, with an error about the column family `merge-operators`, and
leaves it as it was. Take a copy first if you may want to go back.
- **Answers are the same.** A balance or spender that recent blocks changed
costs a read a few microseconds more until RocksDB compacts it.
- Reverting a block reads and writes whole values, as before, and still
checks that a balance does not go below zero.
- **Every table file stays open by default** (`--max-open-files 0`, where it
was 2000): with more files than the limit, a store of Bitcoin Cash opened
some 70,000 files to send one block. Raise the process's limit on open files
above the number of table files.
- **The index and the filter of a table file are written in 4 KiB pieces**,
loaded as needed, where each was one block of up to megabytes. Files already
on disk keep the old layout until RocksDB rewrites them; until then give
the block cache about 1% of the database's size. Needs
`rocksdb-haskell-jprupp` 2.8.0.
- **Lists are read from the database in chunks** (`rocksdb-query` 0.7.0):
one foreign call for a few hundred entries, in constant stack, where there
was one call for each entry. Those calls took some 28% of the processor
time of a busy store.
- **Faster hashing and serialisation.** The hash tables of a batch hash keys
by the hash they already hold, the block store no longer hashes a block's
transactions again, and `stack.yaml` takes haskoin-core, haskoin-store-data
and haskoin-node from commits that serialise on a buffer directly.
- **The heap collects less often.** The executable runs with `-A64m`, 64 MiB
of new objects for each core between collections, where GHC's default is 4:
about 60 MiB more memory a core for far fewer pauses. The collector is GHC's
default again; `GHCRTS=--nonmoving-gc` selects the non-moving one of 1.15.1.
- **No secp256k1 context in the API of the library.** The store is built on
haskoin-core 2.0.0, haskoin-store-data 3.0.0 and secp256k1-haskell 3.0.0,
where the context is global and `Ctx` is gone. The server is the same;
programs that embed the library must change:
- delete `withContext`, `createContext` and every `ctx` passed to this
package; the field `ctx` is gone from `StoreConfig`, `Store`,
`BlockStoreConfig`, `StoreRead` and `DatabaseReader`, and `writerCtx` is
removed;
- `withLayeredReader`, `runWriter`, `deriveFunction`, `toUnspent`,
`valToUnspent`, `poolTx`, `blockChanges`, `seenOf`, `relevant` and
`command` lost their `Ctx` argument and kept the order of the others;
- see the "Migrating" sections of the changelogs of haskoin-core and
haskoin-store-data.
- **No unliftio.** The package uses `base`, `stm` and `async`, and is built on
nqe 0.7.0 and statsd-rupp 0.6.0, whose functions now run in `IO`. No
exported type changed. A program that calls nqe or statsd-rupp from another
monad must lift those calls itself.
- **Peers that hold up blocks are passed over.**
- A peer that delivers nothing for `--block-stall` seconds (ten by default)
is passed over and the next fastest asked for the same blocks; the stall
doubles for each peer passed over, up to the peer timeout.
- Blocks are asked only from peers that announced them, or that gave a
height at least that of the block when they connected.
- The peers that have a block are pinged, and the first to answer is asked;
one slower than `--block-ping` seconds (five by default) only if none
answers in time.
- The peer timeout (`--peer-timeout`) is 30 seconds by default, where it
was 120. A block of 32 MB must arrive within it, which takes a link of
9 Mbit/s: set it higher on a slower one.
- `StoreConfig` and `BlockStoreConfig` have `blockStall` and `blockPing`,
and the block store takes `blockStoreAnnounced` and `blockStorePong`.
- **`Haskoin.Store.Web.Router`:** a `Route` has a `cost`, light, short or
long, and the scope of `routerScoped` is told which route matched.
### Fixed
- **`/events` can watch an xpub again.** Its filter read the cache through
a session with no balances, so every xpub filter failed with 503 or close
code 1013. It now reads in a session of its own.
- **A store whose last block is old still reports to its fleet.** Reports
are gated on being in sync and having peers, not on the age of the last
block, so a quiet chain such as regtest gets a fleet tip.
- **A large wallet is read into the cache ten times faster.** Reloads found
the bodies to read with `nub`, which is quadratic: on a wallet of 45,000
transactions that took 26 of the 28 seconds of its first reload, on 1.15
too. They de-duplicate with a hash set now, in linear time. The addresses
of a new transaction are no longer de-duplicated at all, as a set joins
them anyway.
- **Requests no longer queue up behind each other in Warp's timeouts.**
time-manager 0.3 edits GHC's one timer queue at every pause, resume and
tickle of a connection's timeout, and under load a simple request waited
some 40 ms with a core idle. time-manager 0.4.2 is pinned in `stack.yaml`
and bounded in `package.yaml`.
- **Responses no longer wait for each other for their `Date` header.** Warp
computed its date once a second, and every response waited when the thread
computing it was stopped on a busy core. The store now gives every response
a `Date` of its own, computed twice a second.
- **`store.block` reaches the StatsD server.** It was sent with a sampling
rate of zero, which sends nothing; now with a rate of one.
## [1.15.1] - 2026-11-14
### Added
- **Metrics of the garbage collector.** With `--statsd`, the store sends
GHC's statistics under `rts.*` once a second: collections, the time that
every thread was stopped for them, the CPU that they used, the work of
the non-moving collector, allocation, and the size of the live data and
of the heap. Every collection stops every thread, so they say how much
of a slow answer is the collector's. The executable now runs with
`+RTS -T`, which GHC needs to keep them.
### Changed
- **The old generation is collected while the store runs.** The executable
uses GHC's non-moving collector (`--nonmoving-gc`). The copying collector
stopped every thread while it copied all live data, gigabytes for a store
of mainnet, and under load every request waited for it, `/health`
included. The heap can be larger, as old objects are not moved together.
`GHCRTS=--copying-gc` goes back to the copying collector.
## [1.15.0] - 2026-11-14
Answers decode less of what they read, and write hex faster.
### Changed
- **Raw answers send the transactions as stored.** A raw transaction,
raw block, or the raw transactions of a block, were decoded, built into
their JSON form, with addresses and ids, turned back and serialized
again; and the spenders of their outputs were read for nothing. Now the
bytes of each transaction are found in its stored value and written as
they are. The raw block of 3,011 transactions of the load test takes 21
ms of CPU where it took 60, and its raw transactions 24 ms where they
took 65. This covers `/transaction/:txid/raw`, `/transactions/raw`,
`/transactions/block/:block/raw`, the five `/block/…/raw` routes, and
the hex of `/blockchain/rawtx` and `/blockchain/rawblock`.
- **A block's list of transactions is decoded when it is used.** Reading
a block decoded the hashes of all its transactions, 180 µs for a block
of 3,000, for the many reads that want its height or its header: the
health check, the best block of a request, the median time of a new
transaction, blocks without their transactions. `/block/best?notx=true`
on a block of 3,011 transactions takes 0.06 ms of CPU where it took
0.24, and `/block/latest?notx=true` 31% less.
- **Transactions in JSON are built without serializing them.** Their size
and weight are counted from their parts, and the id of a transaction
read by its id is not computed again (haskoin-store-data's
`toTransactionWithId`). With the faster hex of haskoin-core, 5,000 full
transactions of an address take 20% less CPU, and the 3,011 of a block
21% less.
- **Hex is written faster** (haskoin-core): from a table of digit pairs,
and the hashes of transactions and blocks in one step, five times as
fast. A list of 100 transactions of an address takes 12% less CPU.
- `StoreRead` has `getManyTxBytes`, the transactions as stored, and the
new module `Haskoin.Store.Database.Slices` reads stored values in part.
- The load test's last block holds 3,000 more transactions, when the chain
has 400 blocks or more, and `scripts/bench-web.sh` measures the raw
answers.
## [1.14.0] - 2026-11-14
Long answers are encoded on several cores, addresses are written faster,
and the load-test server works again.
### Changed
- **Long answers are encoded on several cores.** The answers that are
sent in pieces, such as the full transactions of an address, an xpub or
a block, and raw blocks, now encode up to eight pieces at once, as many
as the server has cores. On 5,000 transactions of an address, with eight
cores, a request took 77 ms where it took 176 ms. A server whose cores
are all busy answers about as many requests as before. In the library,
the pieces of `Haskoin.Store.Web.Pieces` are a `Piece`, made with
`piece` from an action that gives bytes, and `piecesResponse` takes how
many to read at once.
- **Addresses are written faster**, with haskoin-core 1.6.3, which this
version needs. Every input and output of a transaction in JSON carries
its address. For 20,000 of them, reading the address from its script
takes 3 ms where it took 33, writing a legacy address 60 ms where it
took 81, and a SegWit address 50 ms where it took 81. CashAddr was fast
already. A whole answer of transactions takes some 30% less to build and
encode.
### Fixed
- The load-test server, `haskoin-store-bench`, builds and syncs again. It
lacked the `nodeRpc` setting of 1.11.0, and it found no peer: since
haskoin-node 2.5 the mock peer has to be named, as the unit tests do.
`scripts/bench-web.sh` measures two answers of 5,000 transactions too,
and `BENCH_LOG=1` prints the log of the server.
## [1.13.0] - 2026-11-13
Transactions are handed over at once, a payment that a block replaced is
answered 410, and what a reorganisation puts back stays in the mempool.
### Added
- **A transaction that a block replaced is answered 410, Gone**, at
`/transaction/:txid` and its raw form, with the transaction of the block
that won (`replaced-by`) and its height, for 2016 blocks. It was 404, as
for a transaction that never was, and a payment that a reorganisation
replaced simply vanished. A store keeps it with the block and deletes it
with its revert. The stores of a fleet keep it in the shared pool, as
the fleet tip moves past the block, and answer from that alike: a
store's own record depends on its own mempool. A transaction replaced in
the mempool is still 404. The client of haskoin-store-data reports the
410 as an error it does not know, until that package learns it.
### Changed
- **`POST /transactions` answers 202, "handed over", at once.** The store
checks the transaction, hands it to every peer, each on a connection of
its own, and answers as soon as they took it, with the id and a message.
It no longer waits up to `--publish-timeout` for a node to announce the
transaction back: the wait was arbitrary, and said less than it seemed,
as Bitcoin Core refuses in silence. The transaction shows in the store
when a node announces it, usually within a second. A transaction that the
store has in a block is still answered 200, and one that a node refuses
over RPC, or that every peer refuses with a reason, 400. The client of
haskoin-store-data takes the new answer as it took the old one.
- With `--node-rpc`, a transaction that the node takes is answered 202 too.
- In the library, `Haskoin.Store.Web.Publish` answers with what was done
(`Answer`: `ToPeers`, `ToNode`, `InBlock` and refusals) in place of
`Verdict`, and has no `Limits` or `Outbox`. `Haskoin.Store.Logic.Layered`'s
`revertBlock` takes the time of the revert, and `Haskoin.Store.Logic` has
`revertBlockAt`, which the tests compare it with.
### Removed
- **`--publish-timeout`** (`PUBLISH_TIMEOUT`), and the outbox that kept
failed transactions from being sent again for ten minutes.
### Fixed
- **Transactions that cost the store its connections are refused.** On
regtest, a signature pushed in a longer form than it needs, and more
CashTokens out than in, both passed the store's checks, and Bitcoin Cash
Node closed every connection of the store when it was sent one. The
store now refuses an input script that does more than push data or
pushes it in a longer form than it needs, tokens that break the rules of
CashTokens, and a version that nodes do not take: 1 and 2 on Bitcoin
Cash, 1 to 3 on Bitcoin. `docs/publishing.md` has what was measured.
- **A transaction that a reorganisation puts back in the mempool stays
there.** It went back with the time of its block, and the store deletes
mempool transactions older than `--mempool-timeout` (14 days) on every
clock tick: a transaction of a block older than that was gone in under a
second, while the nodes kept it. On a regtest chain whose blocks are
older than the timeout, every reorganisation did it. It now goes back
with the time of the revert.
## [1.12.1] - 2026-11-13
### Fixed
- **A transaction that the store has unconfirmed is sent again** when it
is posted again. The store answered 200 at once and sent nothing, as
for a confirmed one. Its mempool is not held to its node's, so it could
list a payment that the nodes forgot, after a reorganisation or when a
node lost its mempool, and the wallet had no way to get it back to them:
on Bitcoin Cash none at all until the store dropped it after 14 days.
Now it goes through the same checks, is given to a node over RPC or on
the courier, and is answered 200 when the node took it, or with the
node's reason. A confirmed transaction is still answered at once.
### Changed
- In the library, the field `has` of `Haskoin.Store.Web.Publish.Publishing`
is now `holds`, which says whether the store has the transaction in a
block, in its mempool or not at all (`Held`).
## [1.12.0] - 2026-11-13
Long lists of transactions and raw blocks are sent while they are read,
and pretty JSON is gone.
### Removed
- **Pretty JSON.** The `pretty` parameter is gone from every endpoint, and
a request with it is refused like any other unknown parameter. Pipe an
answer through a tool such as `jq` to read it indented.
### Changed
- **Long answers are sent while they are read.** The endpoints that answer
with all the transactions that the database lists somewhere read them a
hundred at a time, and send each hundred while they read the next:
- `/address/:addr/transactions/full`, `/address/transactions/full` and
`/xpub/:xpub/transactions/full`;
- `/transactions/block/:block` and `/transactions/block/:block/raw`;
- the raw blocks: `/block/:block/raw`, `/block/best/raw`,
`/block/height/:height/raw`, `/block/time/:time/raw` and
`/block/mtp/:time/raw`;
- `/blockchain/rawblock/:block`, in JSON and in hex, and
`/blockchain/block-height/:height`.
The bytes are the same. With 5,000 transactions of an address (15 MB) on
regtest, the first byte left after 11 ms where it took 96 ms, and sixteen
such requests at once took 197 MB of memory where they took 1,014 MB. The
whole response takes as long as before: encoding JSON is most of it.
- These responses have no `Content-Length`. What can refuse the request is
checked before the first byte; a failure after it ends the response
before it is complete, where it used to be an error with a status.
- Lists that the client names, such as `/transactions?txids=`, are read
whole before they are answered, as before: what is asked for may not be
there.
- The timings of these endpoints count the whole response, the time that
the client takes to read it included.
- No longer depends on aeson-pretty.
- **The warning of a slow request counts the whole response**, until its
last byte is sent. It counted only the time to make the status, which
for an answer sent while it is read is the first hundred transactions.
A client or proxy that reads slowly can now make a request slow. A
response cut short is logged too, ending in `, cut short`.
## [1.11.0] - 2026-11-12
`POST /transactions` is done another way, and now says what came of the
transaction. `docs/publishing.md` has the design and the measurements.
### Changed
- **A 200 means that a full node accepted the transaction and that the
server has it.** It used to mean that the transaction was sent, and came
at once whatever happened. The request now waits for a node to announce
the transaction back, for `--publish-timeout` (`PUBLISH_TIMEOUT`)
seconds at most, 30 by default. With a node that whitelists the store
that takes milliseconds.
- The transaction is handed to one node, on a connection made for it. It
used to go to half the peers, on the connections the store syncs from.
- The transaction comes into the mempool when a node announces it on a
connection that never sent it. The store used to ask the peers it had
sent it to, once, five seconds later.
- The same transaction posted again is sent once, and one that the store
has is not sent at all.
### Added
- The store refuses, with 400 and the reason, a transaction that it can
tell no node will take:
- one that spends an output it does not know, one that a confirmed
transaction has spent, or a coinbase less than a hundred blocks old;
- one whose outputs are worth more than its inputs, or that is a
coinbase;
- one whose lock time has not passed;
- one larger than nodes relay, or with an output that is dust;
- **one with a forged signature**, for coins locked to one key: key
hash, key, witness key hash plain or nested, and Taproot by its key;
on Bitcoin Cash with ECDSA and Schnorr signatures, and for coins that
hold tokens. This is `judgeInputs` of haskoin-core 1.6.2, which also
verifies multisig: with ECDSA signatures on both networks, with
Schnorr signatures on Bitcoin Cash, and the multisig of Taproot.
- `--node-rpc` (`NODE_RPC`): the JSON-RPC URL of a full node. The store
publishes through it (`sendrawtransaction`): the node checks
everything, says why it refuses, which Bitcoin Core does not tell a
peer, and does not close the store's connections over what it refuses.
When the node does not answer, the transaction goes to a peer.
- **A peer is sent only what the store verified.** A transaction with an
input that the store cannot verify, a script that is not a key or a
multisig, is refused with 400 unless the store can send it over RPC. A
peer that finds a transaction invalid may close every connection of
the store, so sending on what it could not judge let anyone cut the
store off from its peers.
- The reason of a node that refuses a transaction and says why, as Bitcoin
Cash Node does, is the message of the 400.
- 500 when no node could be reached, when a node closed the connection on
receiving the transaction, and when no node announced it in time. The
reference always listed these errors; the code gave none of them.
- A transaction that a node refused, closed the connection on, or did not
announce is remembered for ten minutes and not sent again. Other
transactions are published as before.
- The body of `POST /transactions` is read up to the length of the longest
transaction of the network in hexadecimal, and a longer one is answered
413. The server used to read a body of any size into memory.
- `Store` has `connect`, the function that opens a connection to a node.
- The integration tests run a store against a Bitcoin Core and a Bitcoin
Cash Node that do not whitelist it.
### Fixed
- **A published transaction was often not seen until a block confirmed
it.** Bitcoin Core does not give a transaction back on the connection
that sent it until its timer for announcements has run, five seconds on
average: the one request the store made at five seconds got `notfound`
three times in four against Bitcoin Core 32.1. A store whose only node
did not whitelist it then never took the transaction in.
- **One request could cut a store off from half its peers.** A node that
finds a transaction invalid may close every connection from the address
that sent it, and Bitcoin Cash Node 29.2 does. A forged transaction went
to half the peers on the connections the store syncs from.
- With no peer connected the answer was 200 and nothing was sent.
## [1.10.1] - 2026-11-12
### Changed
- `swagger.yaml` names one server, `./`: the server that served it,
wherever it is mounted. It no longer lists the servers of api.haskoin.com,
which describe whatever version those run, not the server in front of
you. The server serves the file as it is, instead of adding itself to
that list.
- The reference page at `/` has no list of servers to choose from and no
bar to load another description: it shows the reference of the server
that serves it, and nothing else.
### Fixed
- The licence links of `swagger.yaml` and `README.md` pointed to a file
that does not exist, and the version in `swagger.yaml` said 1.9.1.
## [1.10.0] - 2026-11-12
The API speaks JSON only. Its binary format is gone, from the server and
from the documentation.
### Removed
- **The binary format.** `Accept: application/octet-stream` no longer
gives binary: every answer is JSON, errors and `/events` included. The
"Binary format" sections of `README.md` and `swagger.yaml` are gone.
Clients built with haskoin-store-data before 2.0.0 ask for binary and
do not work with this server; version 2.0.0 of its client speaks JSON.
- **Binary frames over the WebSocket** of `/events`. Events are sent in
text frames, and a binary frame from the client closes the connection
as a command that cannot be read.
- **Raw bytes in `POST /transactions`.** The body is the transaction in
hex.
### Changed
- Answers have `Vary: Accept-Encoding`, without `Accept`, which no longer
changes what is answered.
- Depends on haskoin-store-data 2.0.0.
### Added
- `docs/fleet-mempool.md`: how the shared mempool of a fleet works, why
it holds, and its weak points. A report in the repository, not in the
package.
## [1.9.1] - 2026-11-11
### Changed
- **The health check runs every second**, where it ran every thirty, and
at once when the store has a new best block. `/health` answers from the
last result, so a load balancer and a fleet acted on news of up to half
a minute ago. Redis is asked every five seconds.
`--health-check-interval` still sets the interval.
- **Log levels say who has the problem.** An error in the log is now
something wrong with the store or its database, so that an alert on
errors is worth having. The README has a table of the levels.
- A transaction from a peer that the store refuses (an orphan, a double
spend, one without funds, one already confirmed) is logged for
debugging. These were errors, several a minute on a healthy server.
- A request answered 4xx or 503 is logged for debugging, like a
successful one. Only a 500 is an error.
- A peer that times out or sends a block that was not asked for is a
warning.
- Redis or the price service not answering is a warning: the store
goes on without them, and `/health` says so.
- **An outage of Redis is logged once when it starts and once when it
is over** (`Haskoin.Store.Outage`), and for debugging in between. The
loops of a fleet and the worker of the cache each logged every failed
attempt, every second or two, and nothing said when Redis was back.
`memberLoop`, `memberCacheLoop` and `memberEvents` no longer take a
function to tell of a failure.
- Each transaction imported into the mempool is logged for debugging,
where it was information.
- With haskoin-node 2.5.1: a peer that hangs up or misbehaves is not an
error, and the comings and goings of peers are logged for debugging.
### Fixed
- **A fleet could stop answering for good after an outage.** A server goes
through 50 blocks at most to tell the shared mempool what they did, and
further than that it may only empty the mempool, which Redis allowed to
a server that was alone. Two or more servers that came back together
more than 50 blocks past the block that the fleet last answered from
each kept the other from moving on, and every request was answered 503
`behind-fleet` from then on.
- Any server may now move the fleet when the way is too long for all of
them (`fleetRestart`, `wayBetween`): the shared mempool is emptied, a
counter in Redis says so (`fleet:restarts`), and every server that
sees it offers its whole mempool again. A server did not notice
before that another one had emptied the mempool.
- A test builds the stuck fleet on purpose, with two members of one
fleet (`Haskoin.Store.Fleet.MemberSpec`).
- **A server that had just started took a turn in its fleet before its
first health check**, reported the blocks that it had then, and with no
other server there moved the fleet to them. It now waits for the check.
### Added
- **A change of health is logged**: a warning with what is wrong when
`/health` stops answering 200, and a line when it does again; the same
for Redis. Nothing said so before but the 503s of the requests.
- **An access log**, off by default: `--access-log` (`ACCESS_LOG`) logs
every request with the address of the client, the status and the time
it took.
- With `--debug`, a member of a fleet says why its report was not taken
and what became of each attempt to move the fleet's block.
- `HASKOIN_TEST_LOG` prints the time of each line, and the lines of the
two stores of the fleet test under their names.
- **A slow request is logged as a warning**, with how long it took:
`--slow-request` (`SLOW_REQUEST`), five seconds by default, 0 for never.
- `stress/results/2026-11-10/`: the results of a full default stress run
on version 1.9.0, with a comparison against the run of the day before on
1.8.1. A cache reload takes 234 ms on average where it took 2,448, and
no longer grows with the xpub.
## [1.9.0] - 2026-11-10
### Added
- `--fleet` (`FLEET`): servers that share a Redis answer as one. Every
request is answered from the newest block that all live servers have and
from one mempool that they share in Redis, so that the same request gets
the same answer whichever server a load balancer picks, also while a
block or a transaction is on its way through them.
- Each server keeps its database as it was at each of its last six
blocks, reports them under a lease of ten seconds, and offers its
unconfirmed transactions to the shared pool. The fleet tip moves in one
step, together with what the blocks in between did to the pool.
- A server that does not have the block that the fleet answers from says
503 with `behind-fleet`. One whose health check fails stops reporting,
and stops counting when its lease runs out.
- Without Redis a server answers from its own database and `/health` says
203.
- `Haskoin.Store.Manager` runs the member (`Store.fleet`), the block
store takes a view of the database right after each block
(`BlockStoreConfig.onBest`), and the web server answers through
`Haskoin.Store.Database.Query.Pooled`.
- An integration test runs two servers as a fleet against a real node and
Redis and compares their answers with a payment in the pool and after
the block that confirms it.
- `docs/layered-database/FleetCost.hs` times a store alone against the
same store in a fleet, with 40,000 transactions in the pool: a fleet
adds about one round trip to Redis to a request. A request is answered
from the tip that the member last read, which its first read of the
pool checks; a transaction's body comes with what spends its outputs;
and a first page is as large as the page asked for.
- A cache of xpubs for a fleet (`Haskoin.Store.Fleet.XPub`), under the
options of the cache of a server alone: `--redis-min-addrs`,
`--redis-min-txs` and `--redis-max-xpubs`. Until now `--fleet` answered
every request about an xpub from the database, with a read of the shared
pool for each address that it touches.
- An entry has the chain's part of a wallet at one block, which is the
same for the whole cache, and the part of the shared pool, which the
script of the pool keeps as it changes the pool. Transactions and
outputs of both are in one sorted set each, in the order of the API.
- The cache answers only while its block is the fleet tip. The server
that moves the tip brings the cache along, with what the new blocks
did at the addresses that entries have. If it does not, or after a
reorganisation, the cache is emptied.
- The cache is at a move of the fleet tip, which the pool counts, and
not just at a block: the tip can leave a block and come back to it.
- Every read of balances runs the scan of the xpub over the entry and
misses unless it reads exactly the addresses of the entry, so a
payment in the pool to an unused address cannot leave the gap wrong.
- Entries are built in the background by the server that missed, and
extended when an xpub gains addresses.
- A request about a wallet of 464 addresses and 19,499 transactions
takes 1.3 to 2.2 milliseconds through it, where a fleet took 5 to 38;
for a wallet with 400 addresses in the pool, 3 to 4 where it took 5 to
126 (`docs/layered-database/fleet-cost.txt`).
- The test of the member compares every answer about a wallet through
the cache with the uncached one after each step of random histories,
and the two servers of the integration test do the same over HTTP.
- StatsD metrics under `fleet.cache.*`: hits, misses, builds and their
time, builds given up, evictions, and the times that the cache was
emptied. The log says why the cache was emptied each time, and with
`--debug` has a line for each entry built and each block that the
cache was brought to.
- Built with `rocksdb-haskell-jprupp` 2.7.1, and every scan by address
uses an iterator that RocksDB stops where the address ends, so that a
scan cannot walk over deleted keys that follow it. The migration reads
the transactions with an iterator that is asked for the order of them
all.
- Built with `haskoin-node` 2.5.0, which has the fixes of its security
review: among them, a block from a peer is checked against its header
before the store sees it, so a peer can no longer pass off transactions
of its choice under a real header. It also allows the new binding. On
regtest its discovery no longer finds a node on this machine: name the
node with `--peer`.
- **`/events` agrees across a fleet.** The servers of a fleet send the
events of the block and the mempool that they share, read from a stream
in Redis that the pool's script writes as it makes each change, and no
longer those of their own nodes. A block is told when the fleet has
moved to it, with every block that it moved through.
- **`/events` takes up where a client left.** `?after=` with the hash of
the last event heard starts the stream after it, over HTTP and over the
WebSocket. The server keeps its last 10,000 events in one log that all
clients read (`Haskoin.Store.Web.Events`), in place of a queue for each.
It answers 404 when it does not have the event. The servers of a fleet
keep the same events, so a client may come back to another one.
- **A WebSocket client chooses the transactions it hears about**: by
address, by extended public key with a type of address, or with a Bloom
filter as in BIP 37, with the commands of `EventCommand` in
`haskoin-store-data` 1.11. Blocks are always sent, and a client that
sends no command hears everything, as before. A key is watched up to its
gap, which moves on with its payments.
- **The choice can be in the URL of `/events`**, so that it holds from
the first event: `quiet=true` for blocks alone, `addresses`, `xpub` with
`derive` (one type or several), and `filter` with `functions`, `tweak`
and `flags`. The HTTP stream takes them too, also under `POST` with a
form. `{"type":"none"}` goes back to blocks alone.
- **The WebSocket speaks binary too**: binary frames when the handshake
asks for binary or the client sends a binary frame, for events and
commands alike.
- **HTTPS**, optional and off by default: `--tls-cert` and `--tls-key`
(`TLS_CERT`, `TLS_KEY`) make the server speak HTTPS on its port.
- **The reference of the API at the root of the server.** `/` is a page
that shows `swagger.yaml` as it was when the server was built, and can
try requests against it; `/swagger.yaml` is the file.
- **`HEAD` and `OPTIONS`** are answered: the headers of what `GET` gives,
and what a browser may send from another site.
- **Answers are compressed** with gzip for clients that accept it, but for
the stream of events.
- **Lists in a body.** The endpoints that take a list of addresses,
blocks, heights or transactions accept `POST` with the parameters in a
form, so that a long list need not fit in a URL.
- **`Retry-After`** on every 503.
- **Errors in binary.** A request that asks for the binary format gets
its errors in that format too, the 503 of a server behind its fleet
included. They were JSON whatever was asked. This needs
`haskoin-store-data` 1.10, whose client reads both.
- **The `Accept` header is read as a list with weights.** Binary is sent
when `application/octet-stream` is listed with a weight above 0 that is
no less than that of `application/json`. The header used to be compared
with that one string, so a list or a weight silently gave JSON. Every
answer has `Vary: Accept`.
- **The raw lists start with a count**, in binary: `/transactions/raw`,
`/block/{block}/transactions/raw` and `/block/height/{height}/raw` were
the one kind of list without it. A binary client of those three
endpoints has to change with the server.
- `haskoin-store --help` names the environment variable of every option.
- `swagger.yaml` documents the binary format: how to ask for it, the
encoding of each type that the API returns, and what differs from JSON.
- Gauges `fleet.cache.xpubs` and `fleet.cache.addresses`: how many xpubs
the cache of a fleet holds, and how many addresses between them.
### Changed
- A WebSocket client of `/events` that sends something the server cannot
read as a command is disconnected, with code 1008 and the reason. What
clients sent used to be ignored.
- The HTTP stream of `/events` no longer holds a view of the database for
as long as its client listens.
- Since version 2.6.4 the binding reads the key and the value of a row of
an iterator without the cost of a safe foreign call.
Every list and every count takes between a half and a third of the time:
the first 100 transactions of a busy address 221 microseconds instead of
575, and the number of transactions of a wallet with 19,499 of them 34
milliseconds instead of 78.
- **Bloom filters are on by default**, as was always meant: until the
binding was fixed, `--bloom` built none. `--no-bloom`, or `BLOOM=false`,
turns them off; `--bloom` is still accepted. An existing database gets
filters, and the memory that they take in the block cache, as its table
files are written again.
- **Transactions that leave the mempool unconfirmed are no longer kept.**
The API already answered 404 for them, but their bodies stayed in the
database, marked as deleted, for ever, and each server had its own.
- A server remembers the last hundred thousand that it deleted, in
memory, so as not to fetch them again from its peers. The fleet's rule
for conflicting transactions and the cache of a server alone, which
both asked the database whether a transaction had been deleted, ask
that memory instead.
- The cache of a server alone takes a transaction that Redis has as
unconfirmed for more than ten minutes, and that the database does not
have, for deleted and not for one that it has not seen yet.
- Bodies that version 20 marked as deleted stay in a migrated database
and are ignored. A page that starts at a deleted transaction is empty.
- Removed reports that no longer describe the store: five intermediate
stress runs, the measurement of a mempool mirrored in memory, and the
superseded runs in `docs/layered-database/query-cost.txt`.
`docs/layered-database.md` is rewritten as a description of what
exists, a quarter of its length.
- **Database version 22: the record of a confirmed transaction is written
once**, by the block that confirms it, and is the same on every server
that has the block, so that what the chain's column families hold
follows from the chain alone.
- **Its time is the time of its block.** A server that had seen a
transaction in its mempool used to keep the time of that when a block
confirmed it: two servers then gave two values of `time` for the same
confirmed transaction, which the servers of a fleet must not do. A
transaction that returns to the mempool when its block leaves the main
chain has the time of that block there.
- **The spenders of its outputs are under keys of their own**, in the
`spender` column family, sixteen outputs to a key (`SpenderKey`).
They were in the record, which each block that spent one of its
outputs read and wrote whole again. A spend now reads and writes a
value of a few dozen bytes and leaves the record alone.
- Reading a confirmed transaction in full takes a second key: 18
microseconds where it took 11.5, and 0.8 milliseconds for a hundred
where it took 0.4. Lists by address and by xpub cost the same, and so
does writing, on the small records of the measurements.
- A database of version 21 is migrated the first time the store opens
it (`migrateRecords`). **It reads every transaction of the database
and writes nearly every one again**, since nothing lists those that
need it and most have a spender in them: many hours for a database of
Bitcoin, and room for a second copy of its transactions until RocksDB
has compacted the first away. The log says how far it is, and it can
be interrupted and started again.
- The tests that run the store through random histories now choose them
from a database of version 20 that goes through the same
(`withShadow`). Given a layered database, the chooser found next to
nothing in the mempool, and the blocks of the tests of the fleet
confirmed almost none of it.
- **Database version 21: the mempool has an area of its own.** Unconfirmed
transactions are no longer written into the indices of the chain. They
are kept apart and applied on top when a query is answered
(`docs/layered-database.md`), so the chain's data changes only when a
block is imported or reverted.
- A database of version 20 is migrated the first time the store opens it,
and the log says how many mempool transactions were moved. **Older
stores refuse the database afterwards**: copy a production database
before upgrading.
- The block store imports with the rules of `Haskoin.Store.Logic.Layered`.
A block that spends an output of a transaction that is only in the
mempool is refused as an orphan; no valid block does that.
- Each request of the web server reads one snapshot of the database for
everything it answers, so the parts of a response agree with each
other. `routerScoped` in `Haskoin.Store.Web.Router` is what gives a
request its snapshot.
- `--wipe-mempool` deletes the keys of the mempool area, in less time
than it took to delete each transaction by the rules, and it no longer
keeps the wiped transactions as deleted ones.
- `StoreRead` has a new query, `getAddressesTxCount`.
- Programs that embed the store and read its database with
`Haskoin.Store.Database.Query` have to move to
`Haskoin.Store.Database.Query.Layered`: the old queries do not see the
mempool of a database of version 21.
- Xpub addresses are derived up to an exact gap: every address up to the last
used one of each chain, then exactly `--xpub-gap` unused ones, and always
the first `--xpub-gap-init` addresses. Addresses used to be read 32 at a
time with the gap checked between batches, so the store looked between 33
and 64 addresses past the last used one, and started counting again at index
20. This is why api.haskoin.com saw a payment 34 addresses past the last
used one, which wallets with a gap of 20 or 32 do not see. Payments that far
away are no longer seen; raise `--xpub-gap` to see them.
- New Redis cache of xpubs (`Haskoin.Store.Cache`), replacing the old one:
- Whenever a transaction touches a cached xpub, or a reorganisation changes
one of its transactions, the store reads the whole xpub again from its
database and replaces the entry in one Lua script, so cached answers are
always answers of the database.
- Everything a response needs is in Redis, transaction bodies included,
shared between xpubs, with the spenders of their outputs kept up to date.
A store that has not imported a transaction yet still serves it.
- Several stores can share one Redis. Each change of a cached xpub is
claimed and applied once, by the first store to see it; stores that catch
up find their changes done and do no work. A store never replaces an entry
that knows more than its database (a higher block, or a transaction it has
not seen), so stores do not undo each other's work, and every entry is
written together with the bodies it needs, so a store that is behind can
serve it in full.
- The rules for claims and for replacing entries are pure decisions
(`Haskoin.Store.Cache.Protocol`). A model test runs several stores
catching up with a chain in random interleavings against a model of
Redis, and checks that they end with the entry of the tip, that no
store replaces an entry with one that knows less, that each change is
written once, and that stores catching up after the first write nothing.
- A reload writes only the differences between the xpub in the database
and its entry in Redis, read in chunks first, instead of rewriting the
whole entry; its script checks that the entry did not change since.
Rewriting an xpub of 15,000 transactions held Redis for up to 77 ms,
during which it answered no other client. A store reloads up to four
xpubs at once.
- A page of the transactions or unspent outputs of a cached xpub is one
round trip to Redis: a Lua script finds where it starts, from the
position of the start transaction in the xpub itself, and reads it.
It took four or five, and read the whole body of the start
transaction to find its position.
- A store marks a cached xpub as used at most every ten seconds, for
eviction, instead of on every read, which made every read a write.
- `--redis-min-txs` (`REDIS_MIN_TXS`, default 1000) also caches xpubs
with at least that many transactions in their addresses, however few
addresses they have.
- Keys start with `hs2:<network>:`, so the cache can share a Redis with the
cache of older versions and with stores of other networks.
- `--redis-max-xpubs` (`REDIS_MAX_XPUBS`, default 10000) replaces
`--redis-max-keys`: the least recently used xpubs past this many are
evicted. `--redis-sync-interval` is removed.
- StatsD metrics: `cache.hits`, `cache.misses`, `cache.reloads`,
`cache.stale`, `cache.evictions` and `cache.reload` (milliseconds).
- `n_tx` of `/blockchain/multiaddr` counts every transaction of the shown
addresses and xpubs, not only those on the page, and `n_tx_filtered` those
that pass the filter. `n_tx` of `/blockchain/rawaddr` for an xpub is its
number of transactions, not the size of the page.
- The web server runs directly on WAI and Warp, without Scotty. Routes,
parameters and passing a request to the next route are in
`Haskoin.Store.Web.Router`, a small router over WAI; a handler is a plain
function from the state of the server and the request to a response in
`IO`, and stops early by throwing an `Except`, which becomes the JSON
error. Every response carries `Access-Control-Allow-Origin: *`, error
responses included. The endpoints, their parameters and their responses
are as before.
- No monad transformers, except conduits, and no functions polymorphic over
`MonadIO` or `MonadUnliftIO`: everything runs in plain `IO`. Database queries are
functions that take the `DatabaseReader` (`Haskoin.Store.Database.Query`);
imports take a `Writer` handle (`Haskoin.Store.Database.Writer`,
`Haskoin.Store.Logic`); the block store and the manager pass their state
explicitly. The classes `StoreReadBase` and `StoreReadExtra` are replaced
by `StoreRead`, a record of the same queries as functions in `IO`, which
`databaseRead` gives for a database; `getTransaction` and the other
helpers of `Haskoin.Store.Common` take it as their first argument. The state
of the web server, which every handler takes as an argument instead of
reading it from a `ReaderT`, holds the queries to answer with, the cache
in front of those about xpubs;
`nocache=true` gives a handler a state whose queries read only the
database. `withStore`, `runWeb`, `runWebSocket` and the `blockStore*`
functions are in `IO`. `WriterT`, `ImportM`, the `StoreWrite` class,
`BlockT`, `CacheT`, `DatabaseReaderT` and `withDB` were removed earlier
in this release. This changes the library API.
- The package uses the GHC2024 edition, with `DuplicateRecordFields`,
`NoFieldSelectors`, `OverloadedRecordDot` and `OverloadedStrings` on for
every module, and explicit deriving strategies.
- haskoin-store-data moves to its own repository,
[jprupp/haskoin-store-data](https://github.com/jprupp/haskoin-store-data),
with its history and its own releases, and haskoin-store moves to the root
of this one; `store/` and `data/` are gone. haskoin-store depends on
`haskoin-store-data ^>= 1.9`. The package has a full description, PVP
upper bounds on every dependency, and no `Setup.hs`.
- Legacy addresses are called `legacy` in the `derive` parameter, the default.
`normal`, the name they had, is still accepted, so old URLs keep working;
it said nothing about the kind of address. Error messages use the new
name. Built with haskoin-store-data at commit `b304acd2`.
- The executable gives memory back to the system as soon as its heap no
longer needs it (`--disable-delayed-os-memory-return` in its default RTS
options). By default GHC marks such memory free for the kernel to take when
it runs short, and Linux counts it as resident until then, so the heap of a
busy store seemed to grow without end, by the size of each peak, with little
live data. The stress test records the resident GHC heap and how much of it
is lazily freed. The heap profile and the runs that found this are in
`stress/results/2026-11-09-memory`, and `scripts/heap-profile-summary.py`
summarises a heap profile.
- The cache brings an entry up to date from what changed, instead of reading
the whole xpub from RocksDB and Redis on every change, which the stress test
showed was almost all the time of a reload, growing to seconds at 100,000
transactions per xpub. A reload reads the changed transactions, the outputs
they create and spend at addresses of the xpub, and the balances of its
addresses, which are compared with Redis's to catch a change the entry
missed. The whole xpub is still read when it is first cached, when the
entry is more than a block behind, when an address with transactions enters
or leaves the gap, when a balance does not match, and every ten minutes.
Entries keep an index of their unspent outputs by outpoint
(`x:<id>:uop`), in format version 3; entries of version 2 are upgraded by
their next reload. New metric `cache.full_reloads`.
- A reload whose balances show changes it was not told of first looks for
them, instead of reading the whole xpub: the transactions that the database
has for the addresses whose balances moved, in the mempool or in blocks
after the one the entry was written at, and the mempool transactions of the
entry that have since been confirmed or dropped, up to 1,000. Under load the
database is often ahead of the events being applied, which made about one
reload in ten of the stress test a full one.
- Bodies that Redis already has, such as those of the transactions that a
block confirms, are rewritten before the commit of a reload, 200 to a
script, instead of in it. The commit of a block that confirms a thousand
transactions of an xpub had about 8,000 arguments and held Redis for 10 to
30 ms, the only commands of the stress test that took that long.
- The scheduled full reload of a cached xpub comes every five to ten
minutes, an interval that depends on the xpub, instead of every ten for
all. Xpubs cached together were read whole together each time: in the full
stress test, four xpubs of tens of thousands of transactions raised the
heap from under 100 MiB to 785 MiB for a few seconds every ten minutes.
- `docs/cache-consistency.md` analyses how a cached xpub can differ from the
database without any check noticing, including spenders of cached
transactions that no reload repairs, and what would prevent it.
- `docs/layered-database.md`: a design for keeping the mempool out of the
chain's indices, in an area of its own that is applied on top when a query
is answered, with the measurements behind it and what it means for the
cache. The store still runs on the layout of version 20; this adds the
parts that could be proved ahead of the switch:
- `Haskoin.Store.Database.Types` has the keys of the mempool area
(`MemSpenderKey`, `MemAddrKey`, `MemDeletedKey`) and a marker for
migrations that work in several writes (`MigrationKey`).
- `Haskoin.Store.Database.Mempool` has the keys that one mempool
transaction contributes, and what the mempool does to the balance and
the unspent outputs of an address.
- `Haskoin.Store.Database.Migrate` moves a database of version 20 to the
layered layout without a resync: it takes every mempool transaction out
of the chain's indices and writes it to the mempool area, in atomic
batches that can be interrupted. Nothing calls it yet.
- `withLayeredReader` opens a database with the extra column family,
`mempool-addr`, that the layout needs.
- Tests build databases with the store's own rules from random histories
of payments, blocks, replacements, deletions and reorganisations,
migrate them, and check that every query answers as before, that the
chain's column families are those of a database that never saw a
mempool, and that emptying the mempool area leaves the chain's answers.
- `Haskoin.Store.Logic.Layered`: the rules that import and revert blocks
and add, replace and delete mempool transactions in the layered layout of
`docs/layered-database.md`, with the functions, results and errors of
`Haskoin.Store.Logic`. Blocks are written to the chain's column families
alone, and the mempool to its own area. The store does not use them yet.
- `Haskoin.Store.Database.Writer` can write the mempool area in the same
atomic batch as the chain; batches of today's rules write nothing there.
- Tests give the same random history to both sets of rules, on Bitcoin and
on Bitcoin Cash: payments, replacements, deletions, blocks in and out of
order, reorganisations, and transactions and blocks that must be
refused. Every operation must have the same result and move the same
transactions in and out of the mempool, every query must answer the same
after it, and at the end the database of today's rules, once migrated,
must equal that of the new rules key for key.
- One difference is on purpose: a block that spends an output of an
unconfirmed transaction is refused by the new rules, as that output is
not in the chain. Today it is imported.
- `Haskoin.Store.Database.Query.Layered`: every query of the store for the
layered layout, with the names and arguments of
`Haskoin.Store.Database.Query`, and `layeredRead`, which gives them as the
record of queries that the web server answers with. The store does not use
them yet.
- A query takes a `View`, a RocksDB snapshot that only `withView` makes,
so that the chain and the mempool are read as they were at one moment.
- Pages are cut from the mempool's part of a list followed by the chain's
part, by today's rules for starts, offsets and limits, for one address,
for several, and for extended public keys.
- Mempool spenders are looked up only for the outputs of a transaction
that no block spends, in one multi-get for a whole page of transactions.
- `MemDeletedKeyP` matches deleted transactions by the start of their
hash, for the short transaction numbers of the Blockchain.info API.
- Tests ask today's queries and the new ones for pages with random
limits, offsets and starts, on databases migrated from today's layout,
on databases built by the rules of the layered layout, and on databases
upgraded in the middle of a history. They also check that an open view
goes on answering from its moment while blocks and transactions are
written.
- A summary for each address that the mempool touches, in the layered
layout (`MemSummary`, under `MemAddrSumKey`): the number of its mempool
transactions, and the amounts and numbers of the outputs that the mempool
pays to it, spends, and both pays and spends. The measurements showed the
queries of that layout to be too slow for an address with much in the
mempool, and for any address right after a block, because they scanned
everything that the mempool has for an address to answer anything.
- A balance is now two reads by key, and an address with nothing in the
mempool is found by a key that is not there.
- Lists of transactions and of unspent outputs read the mempool's entries
only for addresses that have some, and only as far as the page goes.
- The rules keep the summary with every transaction that enters or leaves
the mempool, and the migration writes all of them from the entries that
it moved. The tests work every summary out again after each operation.
- Measured again with `QueryCost.hs`: the balance of an address with
6,216 entries in the mempool takes 11 microseconds instead of 35
milliseconds, a page of its transactions what it takes in version 20,
the balances of a wallet of 464 busy addresses 1.9 milliseconds instead
of 110, and nothing gets slower right after a block. Keeping the
summaries costs about 110 microseconds for each transaction that passes
through the mempool. `docs/layered-database.md` has the tables.
- `docs/layered-database/QueryCost.hs` writes one synthetic history into a
database of each layout and times the rules and the queries of both,
checking that the answers agree. `docs/layered-database.md` has the
results and what follows from them: writing costs the same when syncing
and 14% more for a transaction that passes through the mempool; the new
queries cost 10 to 15 microseconds more for a request when the mempool
has nothing for what is asked; and they are too slow, as built, for
addresses that the mempool touches a lot and for any address right after
a block. The document proposes a summary for each address in the mempool
area, read by key, and two changes to the RocksDB binding.
- Documentation: a page that starts at a height has no unconfirmed
transactions, whatever the height. The comment on `AtBlock` said that a
height above the best block includes them, and the API reference could be
read that way. The behaviour is unchanged.
- The stress report breaks the commands that blocked Redis down by script,
and commits by full and incremental reloads, with their numbers of
arguments.
- `Haskoin.Store.Fleet`: the rules by which stores that share a Redis agree
on one block to answer from, the fleet tip, as pure decisions with a model
test. It is the first part of the design for a fleet that answers as one,
in `docs/layered-database.md`. Nothing uses it yet.
`Haskoin.Store.Fleet.Redis` carries the rules out against Redis, with a
Lua script for each step that has to be one step, and a test that takes
random sequences of steps through a real Redis and through the rules and
compares them after each. `Haskoin.Store.Fleet.Pool` has the rules of the
mempool that such stores share, as of the fleet tip: what may be offered,
which of two conflicting transactions stays, what leaves and why, and how
the pool follows the tip forwards and across a reorganisation. A model
test keeps it valid on top of the tip through random offers, blocks and
reversals. One more Lua script carries these rules out, moving the tip and
changing the pool in one step, and is compared with them step by step in a
real Redis like the others; the comparison found a case that the rules had
left open, a transaction that comes back from an abandoned block and
spends what the pool already spends, which now wins. The pool also keeps,
for each address, what its transactions do there: the transactions and
the outputs paid to it in the order of a list, the outputs of it that are
spent, and their sums, so that a balance is one read and a list is read
by the page, as in a store's own mempool area.
- `Haskoin.Store.Database.Query.Pooled`: the queries of the store with a
mempool that is not its own on top of the chain, for the shared pool of a
fleet. `read.lua` and `poolRead` read that pool from Redis, each read
with a check that the fleet tip has not moved. The tests hold these
queries to those of the layered layout with the store's own mempool as
the pool. `fleetAdvance` can empty the pool for a store that is alone and
does not know the way from the old tip.
- `Haskoin.Store.Fleet.Member`: what a store does as a member of a fleet.
It keeps a view at each recent block, reports them, moves the fleet tip
with what the blocks in between did to the pool, offers its mempool, and
answers from the view at the tip with the pool on top. A test with a real
Redis takes a store that is alone in its fleet through random histories
and compares every answer with the store's own after each step. It found
that a body kept in the pool went stale when a parent was confirmed or
came back, because a transaction inherits from its unconfirmed parents
whether it can be replaced by fee; the pool now keeps that apart from the
body and corrects it as transactions come and go.
- `Haskoin.Store.Database.Views` keeps the database as it was at each recent
block, a RocksDB snapshot for each, so that a store can answer from the
block that its fleet agrees on and not only from its newest. Views that
are no longer needed are let go, and one that a request is reading is
released when the request is done. Nothing uses it yet.
- A store whose Redis does not answer goes on answering from its database,
instead of failing every request that the cache would have served. A
request waits at most two seconds for Redis; after that the store leaves
Redis alone until a health check finds it again. Meanwhile `/health`
answers 203, Non-Authoritative Information, with the header
`Haskoin-Degraded: redis`, when every other check passes: a status in the
200s, so that load balancers keep the store, and not 200, so that
monitoring notices. The body of `/health` has a new check, `redis`, for a
store that has a cache; it does not count towards `ok`. It comes with
haskoin-store-data 1.9.0, which the store now takes from Hackage.
- Breaking: transactions that were deleted are no longer returned. A
transaction that was replaced, dropped from the mempool, or was the
coinbase of a block that left the main chain used to answer by id with
`"deleted": true`; clients that did not look at that field took it for a
pending payment. It now gives 404, is left out of lists of transactions
fetched by id, and a page cannot start at it. The `deleted` field stays in
responses and is always false. The bodies stay in the database.
- Breaking: parameters are checked. A request with a parameter that its
endpoint does not accept, such as a misspelt `limt=10` or `pretty` on the
Blockchain.info endpoints, which never honoured it, gives 400
`Unknown parameter: …`; and a value that cannot be read, such as
`notx=yes`, `limit=-1`, `filter=4`, `format=xml` or an unknown currency,
gives 400 `Invalid value for parameter …`. Both used to be ignored, and
the client got an answer to a question it did not ask. Requests are
checked before anything is done. The Blockchain.info endpoints accept
`format=json`, which their clients often send. Each route of the router
declares the parameters it accepts, and reading an undeclared one is an
error of the program, so the two cannot drift apart.
- An xpub asked about with the wrong `derive` gives 400, with a message that
names the right kind, instead of an empty wallet: when the xpub has no
transactions with the kind asked for, the store checks the first
`--xpub-gap-init` addresses of the other kinds. This applies to the `/xpub`
endpoints and to `/blockchain/rawaddr`. A wallet unused with every kind
still gets an empty answer, and wallets in use cost nothing more.
- `swagger.yaml` explains the API, not only lists it: an introduction to its
conventions (amounts, ordering, paging, formats, errors, unconfirmed
transactions, reorganisations, xpubs, live events, Blockchain.info
compatibility) and the reasons for them, and a description of every
endpoint, parameter and field. It documents `/dbstats`, the WebSocket at
`/events` and the `time` field of the health check, which were missing,
and corrects the health check examples and the version.
- The README tutorial pages with `height`, the parameter the server reads;
it said `start`, which the server ignores.
- Every line of code is shorter than 120 columns, `swagger.yaml` included,
whose long hexadecimal and xpub examples are split into equal pieces that
parse to the same values. `scripts/format` formats `integration/` and
`stress/` too.
- Scripts live in files of their own: the Lua scripts of the cache in
`src/Haskoin/Store/Cache/lua/`, embedded at compile time with
`file-embed`; the script of wrk in `stress/wrk.lua`, one for every
endpoint, given its paths on the command line; and the shell steps of CI
in `scripts/check-local-deps.sh` and `scripts/install-system-libraries.sh`.
The scripts do the same as before.
### Fixed
- `--bloom` builds Bloom filters. It built none when the store was built
against RocksDB 6.24 or later, as the Docker image is, because
`rocksdb-haskell-jprupp` passed the size of the filter to RocksDB with the
wrong type. Nothing failed; a lookup of a key that is not there just went
on reading data blocks to find that out. The store is now built with
`rocksdb-haskell-jprupp` 2.6.3, which has the fix. A store that already
runs with `--bloom` starts building filters when it is upgraded, for the
table files written from then on: about 1.25 bytes for each key, held in
the block cache. Size that on a full database, or turn the option off to
keep things as they were.
- `--bloom` no longer asks for filters on the two indices by address, which
are scanned and not read by key. With a filter, a scan of an address that
has nothing steps over every key deleted since the last flush: 810
microseconds after 5,000 mempool transactions were deleted, against 13
without filters. No store was affected, because no filter was ever built;
with the fixed binding they would have been. The option still builds
filters for transactions, unspent outputs, blocks, balances and the
mempool.
- `/blockchain/multiaddr` no longer reads every transaction of the wallet to
count them. `n_tx` of one xpub is its count (a `ZCARD` when it is cached);
for several xpubs and addresses, the database counts the distinct
transactions of all their addresses from the keys of its index. The
transactions of a page are read in pages of about the size asked for, and
their bodies a page at a time, instead of one by one; `/blockchain/rawaddr`
does the same. In the stress test, with xpubs of about 15,000
transactions, the median time of a multiaddr request went from 3.2 seconds
to 36 milliseconds, and it no longer grows with the wallet.
- Containers left by an integration test run that was killed are removed
by the next run, as intended: listing them used a template that Podman
refuses, so they were never found.
- `--peer HOST[:PORT]` works as documented. It was read as a Haskell
string, so only `--peer '"HOST:PORT"'`, with the quotes, was accepted.
- The syncing peer is disconnected when it sends a block that was not
requested, as the documentation of the block store said. The block was
imported if the node knew its header. The state of the block download is
now a pure state machine (`Haskoin.Store.BlockStore.Sync`) with property
tests, which also found that a block listed twice in one request was
outstanding twice.
- The block store no longer starts a thread for every transaction it
requests, to forget the request twenty seconds later. Requested and
received mempool transactions are one pure value
(`Haskoin.Store.BlockStore.Pending`), with property tests, and old
requests are forgotten on the clock tick of the block store.
- Build against haskoin-node 2.4.0, from the head of its
`fix-header-sync-stall` branch. The block store reserves its syncing peer
as an owner of its own (`reservePeer`, `releasePeer`), so no other part of
the node can release it; header searches run with `chainRunHeaders`. The
store stopped following the chain
when a peer announced new blocks with an inventory message instead of
headers, which peers do when many blocks are found at once; it stayed at
the old height until the peer reconnected.
- Mempool transactions that entered the mempool in the same second could be
listed twice in the transactions of an xpub or a multiaddr wallet, and
their order differed from page to page. Every merge now orders them as the
database and the cache store them (`txRefKey`, `unspentKey`).
- `nocache=true` on `/xpub/:xpub/transactions` and `/xpub/:xpub/unspent` no
longer reads, or fills, the cache.
- `confirmations` of `/blockchain/unspent` no longer wraps around for an
output in a block newer than the chain of the store.
### Added
- `scripts/stress-cache.sh`, a stress test of the Redis cache: a regtest
chain, Valkey and wrk in Podman, a haskoin-store server, hundreds of
thousands of transactions between a few wallets, and wrk on their xpubs
all the while, with a report (`scripts/stress-report.py`) of reloads,
lag, resources, the commands that blocked Redis (from its slow log) and
latencies, and a check of the cached answers at the end. The Podman
helpers of the integration tests are an internal library (`integration`)
that the stress program shares, and the test image has wrk in a layer of
its own.
- `stress/results/2026-11-09/`: the results of a full default stress run,
kept for comparison with later runs.
- `runWebSocket` serves the API on a socket that already listens. The tests
bind port 0 and pass the socket, so their web servers get free ports with
no window in which another program could take them; the containers publish
their ports on random ports of the host.
- Integration tests against regtest chains of Bitcoin Core and Bitcoin Cash
Node, with Valkey, in Podman containers built from Ubuntu 26.04 and
release tarballs checked against pinned hashes, one cached layer per
download, so nothing is downloaded twice. They are skipped when Podman
cannot run containers or `HASKOIN_STORE_NO_PODMAN` is set.
## [1.8.1] - 2026-11-07
### Changed
- Documentation: the README explains the purpose and design of the store, with
installation steps, a full configuration reference, monitoring and a
tutorial, and the Haddock of every module and function says why it works the
way it does.
- Build against nqe 0.6.9, rocksdb-haskell-jprupp 2.6.1, rocksdb-query 0.6.1,
statsd-rupp 0.5.0.2, secp256k1-haskell 2.0.1, haskoin-node 2.3.1 and
Stackage nightly-2026-11-07.
## [1.8.0] - 2026-11-07
### Changed
- Index the mempool by the time each transaction entered it. `/mempool`,
`/blockchain/unconfirmed-transactions` and the health check read only the
page they return, newest first, instead of loading and sorting the whole
mempool on every request. Data version 20: a version 18 or 19 database is
migrated when it is opened, with no resync.
- The block store no longer reads the whole mempool to publish mempool
events, to set the mempool gauge or to find expired transactions. Each
import reports which transactions it added to the mempool or removed from
it; pruning reads only the oldest entries of the index. Before, every
block, every batch of new transactions and every clock tick (several per
second) read the whole mempool at least once.
- Count the transactions of an xpub without building the list of all of them
when the cache is not used.
- Keep the derived addresses of the 512 to 1024 most recently queried xpubs
in memory. Every xpub query derived each address again before reading a
balance. Addresses depend only on the xpub, so the cache never goes stale.
- Page the unspent outputs of an xpub by merging its addresses in order of
block, stopping once the page is full, instead of decoding up to offset
plus limit outputs of every address and sorting them all. The pages are
the same.
- Count the transactions of an xpub by merging the raw keys of its
addresses, without decoding keys or reading values.
- Open the iterators of a query over many addresses in one bracket instead
of one bracket each. Every call into RocksDB walked the stack past one
frame per address.
- Double the page, up to 1024 rows, when streaming a source by offset, as
`/blockchain/unspent` does. The rows read and skipped grew with the square
of the rows returned.
- Check that an xpub is cached in the same Redis round trip as the read of
its balances, transaction count, or a page of its transactions or unspent
outputs that does not start at a transaction.
- Serialize a transaction at most twice to compute its id, size and weight,
and stop looking up its witnesses with a quadratic list index.
- Build on haskoin-core 1.6.1, which encodes CashAddr and Base58 addresses
faster: about 10% less CPU per request on endpoints that return many
addresses.
- The executable uses every core of the host by default (`-N` instead of
`-N4`). Set `+RTS -N<n> -RTS` on the command line to choose a number.
- Read the balances of many addresses, and lists of transactions, with one
RocksDB multi-get instead of one read per key. `StoreReadBase` has a new
method, `getManyTxData`, which defaults to reading the transactions one by
one; `getTransactions` reads many transactions with it.
- Give RocksDB a block cache of 1 GiB by default, shared by all column
families, and keep their index and filter blocks in it at high priority,
with those of level 0 pinned. Before, each column family had RocksDB's
default cache of 32 MiB, and index and filter blocks stayed in memory
outside any cache for every open file. Set the size with `--block-cache-mb`
or `BLOCK_CACHE_MB`; 0 restores the RocksDB defaults. `StoreConfig` and
`withDatabaseReader` take the size in bytes. Requires rocksdb-haskell-jprupp
2.6.0.
### Added
- `store/bench`: a benchmark server that syncs a synthetic regtest chain and
serves the web API on it, and times the encoding of a response with the
argument `micro`. `scripts/bench-web.sh` runs wrk against it and reports
the CPU time of the server per request.
## [1.7.0] - 2026-11-06
### Changed
- Build on haskoin-core 1.6.0 and haskoin-node 2.3.0, the releases with the
fixes of the November 2026 security review. Their changelogs list the
changes to message parsing, header validation and peer handling that the
store now runs with.
- An output has an address only when the network defines one for its script,
as in haskoin-core 1.6.0. A SegWit-shaped output has no address on Bitcoin
Cash. A 256-bit script hash output (`OP_HASH256`, a push of 32 bytes,
`OP_EQUAL`) has none on Bitcoin. Such an output is no longer indexed under
an address, and its `address` is `null`. Entries that an older version
wrote under such an address stay in the database. No request can name them,
since the address has no text form on the network.
- `POST /transactions` takes a body that holds one transaction and nothing
else. Bytes after the transaction are refused, as Bitcoin Core does for a
raw transaction. They used to be ignored.
- `POST /transactions` takes the transaction in the format that peers of the
network read. A network without SegWit, such as Bitcoin Cash, has the
format without witness only.
- `GET /peers` gives the `version` of a peer as a signed number, as
haskoin-core 1.6.0 reads it. A peer that sends version ffffffff has version
-1, where it used to appear as 4294967295.
- Breaking, in `haskoin-store-data`: `toTransaction` takes the `Network` as
its first argument, and the `version` field of `PeerInfo` is an `Int32`.
The binary form of `PeerInfo` is the same bytes as before.
- From haskoin-node 2.3.0: a peer is disconnected when it sends more than
50000 entries in an `inv` or `getdata` message. On Bitcoin Cash a message
may be at most 2 MiB, unless it carries block content. Transactions from
Bitcoin Cash peers are read in the format without witness only.
### Fixed
- A response no longer fails on a transaction with an output that has no
address on the network. Since haskoin-core 1.5.0 the JSON encoder of such
an address threw, which cut the response off. One such output is in Bitcoin
block 211997 (transaction
`a4bfa8ab6435ae5f25dae9d89e4eb67dfa94283ca751f393c1ddc5a837bbc31b`,
output 0).
## [1.6.5] - 2026-11-04
### Fixed
- Build on haskoin-core 1.5.1, which evaluates the ASERT difficulty rule at the
parent block. With 1.5.0 the store rejected a valid block on Bitcoin Cash
mainnet at height 975899.
## [1.6.4] - 2026-11-04
### Added
- Support Bitcoin testnet4 (`NET=btctest4`), from haskoin-core 1.4.0.
- Option `--block-window` (`BLOCK_WINDOW`) to set how many blocks to request
from the syncing peer at a time.
- Option `--write-buffer-mb` (`WRITE_BUFFER_MB`) to cap RocksDB memtables
across all column families, 256 MiB by default (0 = unlimited). Without a
cap the nine column families can keep up to 1.1 GiB of memtables.
- Option `--max-wal-mb` (`MAX_WAL_MB`), 1024 MiB by default (0 = RocksDB
default), to bound the RocksDB write-ahead log: once it is larger, the
column families holding its oldest file are flushed so the file can be
deleted.
- `/dbstats` starts with the memory RocksDB uses outside the GHC heap:
memtables and table readers for each column family, and the block cache.
- The mempool is kept in its own column family, one key per transaction,
instead of as a single list value that every import batch read, loaded
into a hash table and wrote back whole. Data version 19: a version 18
database is migrated when it is opened, with no resync.
### Changed
- Replace monad-logger with the fast-logger `Logger` from haskoin-node 2.0.0.
- Request 64 blocks at a time from the syncing peer instead of 500, and ask
for more once fewer than 16 remain, to bound memory use while catching up.
- haskoin-store-data builds against secp256k1-haskell 2.0.0, which hides the
raw `PubKey` constructor: `XPubSpec` reads its stored key with `pubKey`,
which checks it.
- Build on haskoin-core 1.5.0, haskoin-node 2.1.2 and secp256k1-haskell 2.0.0.
`genesisBlock` no longer takes a context.
- A pay-to-public-key output has no address any more, as in haskoin-core
1.5.0. Its coins cannot be spent with the input script of the P2PKH address
of the same key, so they are no longer counted under that address.
- The block store no longer reads the whole mempool four extra times on every
internal ping: it compares mempool snapshots only when there are pending
transactions to import or expired ones to delete.
- Run with four capabilities (`-N4`) instead of one per core (`-N`), so that
memory overhead does not grow with the size of the host. Override with
`+RTS -N<n> -RTS`.
- Docker image: pin the base image to Debian trixie (RocksDB 9.10) by digest
instead of `debian:latest`, and run with `MALLOC_ARENA_MAX=2` to limit
malloc fragmentation from RocksDB.
- Each `/events` client, websocket or HTTP stream, gets a queue of at most
10,000 events and is disconnected when it fills up, instead of the queue
growing for as long as the client stays connected. Store events that
`/events` does not show are no longer queued for its clients.
- A request waiting for another to load an xpub into the cache retries for
about 30 seconds, with at most 5 seconds between attempts, and then serves
the xpub from the database. It used to retry forever with a delay that
doubled each time.
- Continuous integration on GitHub Actions: build, run both test suites,
and check that the heap stays flat while syncing 6000 regtest blocks.
### Fixed
- Support full-RBF: accept replacements of transactions that do not signal BIP125.
- Correct various space leaks.
- `Unspent` implements `coinInputKind`, new in haskoin-core 1.5.0, from its
output script, so coin selection with it no longer fails at run time.
### Added
- Support for testnet4 on both networks.
## [1.6.3] - 2026-08-31
### Added
- Allow disabling web server to sync block chain only.
## [1.6.2] - 2026-08-13
### Fixed
- Fix upstream regressions in haskoin-node.
## [1.6.1] - 2026-08-13
### Fixed
- Support latest version of haskoin-node.
## [1.6.0] - 2026-08-12
### Fixed
- Support for Bitcoin Cash 256-bit scripts.
- Address parsing now allows only correct lengths.
## [1.5.16] - 2025-05-08
### Changed
- Move to personal repository.
### Removed
- Disable `NO_SLOW` as an option.
### Added
- Allow to set `NO_XPUB` to disable extended public keys.
## [1.5.14] - 2024-12-04
### Changed
- Move `/dbstats` and `/mempool` to slow endpoints section.
### Added
- Cull old transactions from mempool automatically.
## [1.5.13] - 2024-10-25
### Changed
- Dummy release: update upstream LTS Haskell dependency in `stack.yaml` file.
## [1.5.12] - 2024-07-22
### Added
- Metric to track time to import a new block.
- Parameter `no_compact` allowed for backwards compatiblity.
## [1.5.11] - 2024-05-24
### Fixed
- Parameter `noCompact` corrected for `multiaddr` endpoint.
## [1.5.10] - 2024-05-24
### Fixed
- Prune obsolete transactions from outgoing peer requests.
- Remove unnecessary module imports.
## [1.5.9] - 2024-05-23
### Fixed
- Only sync mempool once for each peer.
## [1.5.8] - 2024-05-23
### Fixed
- Dummy release to bump upstream dependency on `haskoin-node`.
## [1.5.7] - 2024-05-23
### Fixed
- Dummy release to bump upstream dependency on `statsd-rupp`.
## [1.5.6] - 2024-05-22
### Changed
- Allow to toggle RocksDB Bloom filters off.
### Fixed
- Correct command-line option behaviour for some rarely-used parametres.
## [1.5.5] - 2024-05-19
### Changed
- Lock Redis before checking if the database needs to be pruned, rather than after.
- Lock xpub in Redis to avoid computing derivations multiple times.
### Fixed
- Rename redis-min-gap to redis-min-addrs to match environment config variable.
## [1.5.4] - 2024-05-07
### Fixed
- Fix Redis bug where old keys weren't pruned quickly enough.
### Changed
- Remove Nomad-specific environment variable parsing for statsd.
## [1.5.2] - 2024-04-24
### Changed
- Use default GHC garbage collector.
## [1.5.1] - 2024-04-23
### Changed
- Compile with GHC 9.8.2.
- Enable optimisations.
## [1.5.0] - 2024-04-06
### Fixed
- Use an optimised topological sort for importing transactions in bulk.
## [1.4.0] - 2024-03-27
### Changed
- Use default optimisation settings.
- Use default RocksDB parameters.
## [1.3.0] - 2024-03-14
### Changed
- Bump upstream dependencies.
## [1.2.5] - 2023-01-31
### Fixed
- Test suite now working again.
## [1.2.4] - 2023-01-31
### Changed
- Bump upstream dependencies.
## [1.2.3] - 2023-12-06
### Changed
- Transactions received via POST are just forwarded to every peer without delay or validation.
- Bump dependency on NQE to resolve async issue.
## [1.2.2] - 2023-10-21
### Fixed
- Fix comparison function for unspent outputs.
### Changed
- Avoid deprecated `param` function from Scotty.
## [1.2.1] - 2023-10-04
### Fixed
- Correct web exception output format (JSON).
- Correct block path parsing order.
## [1.2.0] - 2023-10-03
### Changed
- Upgrade `scotty` dependency and fix incompatibilities.
## [1.1.0] - 2023-09-15
### Added
- Add cache height stats.
- Add database iterator stats.
### Changed
- Detect xpub gap more strictly.
- Use statsd-rupp instead of ekg-stats.
- All stat reporting keys changed.
### Removed
- Remove unsafeInterleaveIO from Web.hs.
- Remove unnecessary WAI middlewares.
- Remove server and client error reporting per endpoint.
## [1.0.2] - 2023-08-25
### Changed
- Code refactoring and simplification.
- Improve logging output.
### Removed
- Do not impose time limits on REST API responses.
### Fixed
- Remove loop in Blockchain.info unspents function.
- Correct documentation for /blockchain/rawblock endpoint.
- Fix no match in record selector address for coinbases.
## [1.0.1] - 2023-08-03
### Changed
- Add compatibility with latest nightly LTS Haskell.
## [1.0.0] - 2023-07-28
### Changed
- Compatibility with latest haskoin-core and haskoin-node packages.
- Use DuplicateRecordFields and OverloadedRecordDot language extensions.
- Modernize package in a backwards-incompatible manner.
- Refactor package extensively.
## [0.65.10] - 2023-05-12
### Changed
- Revert to older LTS Haskell to attempt to resolve memory leak.
### Removed
- Remove unnecessary lock release.
## [0.65.9] - 2023-05-09
### Changed
- Be more aggressive caching individual transactions.
- Introduce a periodic cache mempool sync task.
## [0.65.8] - 2023-05-08
### Changed
- Perform health check in separate thread.
## [0.65.7] - 2023-05-05
### Changed
- Do not sync mempool to Redis if node is not up-to-date.
## [0.65.6] - 2023-05-04
### Changed
- Improve caching ingestion performance.
## [0.65.5] - 2022-09-19
### Added
- Fee field added to Blockchain.info-style export-history endpoint.
### Changed
- Bump version due to Git mistake.
## [0.65.3] - 2022-04-13
### Added
- IPv6 peer support.
## [0.65.2] - 2022-04-13
### Fixed
- Correct lazy bytestring deserialization algorithm for web client.
## [0.65.1] - 2022-04-13
### Changed
- Simplify function in Cache module.
- Bump depenedencies.
## [0.65.0] - 2022-02-03
### Changed
- Spenders now embedded into tx objects in database for performance.
- Use faster IORef instead of slow TVar when ingesting.
- Use mutable hash tables when ingesting.
- Allow to disable unscalable API endpoints.
## [0.64.19] - 2022-02-01
### Added
- Allow to set query timeouts.
## [0.64.18] - 2022-01-21
### Fixed
- Off-by-one error when importing change addresses to cache.
## [0.64.17] - 2022-01-21
### Fixed
- Add change addresses to cache when necessary.
## [0.64.16] - 2022-01-10
### Fixed
- Correct fee calculation for blocks that do not claim all rewards.
## [0.64.15] - 2022-01-07
### Fixed
- Correct scale of cache pruning code.
## [0.64.14] - 2022-01-07
### Fixed
- Always prune to 80% of max cache size.
## [0.64.13] - 2022-01-07
### Fixed
- Avoid doing a hissy fit on transient cache issue.
## [0.64.12] - 2022-01-07
### Fixed
- Prune a little more cache to allow for new keys.
## [0.64.11] - 2022-01-06
### Fixed
- Prune cache more often.
## [0.64.10] - 2021-12-30
### Changed
- Return empty addresses in xpub balances call.
## [0.64.9] - 2021-12-29
### Fixed
- Avoid notifying same transactions in mempool.
## [0.64.8] - 2021-12-26
### Changed
- Use better Fourmolu format.
- Be more precise when counting retrieved items.
### Fixed
- Avoid transactions duplicated in xpub data.
- Refactor some functions to make them more robust.
## [0.64.7] - 2021-12-26
### Fixed
- Optimisations for various Blockchain endpoints.
- More accurate item counts for various web endpoints.
## [0.64.6] - 2021-12-25
### Fixed
- Record cache index time just once per xpub.
## [0.64.5] - 2021-12-25
### Changed
- Add suffix cached to cache entries to avoid conflicts with data entries.
## [0.64.4] - 2021-12-25
### Fixed
- Bring dots back and avoid stats hacks.
## [0.64.3] - 2021-12-25
### Fixed
- Fix typo.
## [0.64.2] - 2021-12-25
### Changed
- Replace dots for underscores in metrics.
## [0.64.1] - 2021-12-25
### Changed
- Automatic formatting.
- Improve cache debug logging.
### Fixed
- Add item count to 'all' query metrics.
## [0.64.0] - 2021-12-25
### Changed
- Improve metrics.
### Fixed
- Get lock before importing transactions to cache.
## 0.63.0
### Fixed
- Make cache updates lightweight.
## 0.62.1
### Fixed
- Fix idempotent transaction elimination bug.
## 0.62.0
### Added
- Configurable Blockchain price URLs.
- Reuse HTTP connections with wreq sessions.
## 0.61.1
### Changed
- Upstream improvements on Base58 performance.
## 0.61.0
### Fixed
- Fixed recursion bug in Blockchain format conversion function.
## 0.60.0
### Fixed
- Correct notifications subsystem.
## 0.59.0
### Fixed
- Correct internal dependency.
## 0.58.0
### Fixed
- Correct output freeing algorithm.
## 0.57.0
### Changed
- Report errors freeing outputs.
## 0.56.0
### Changed
- Report all deleted mempool transactions.
- Crash on certain data corruption.
## 0.55.0
### Changed
- Always have a previous output object in Blockchain inputs.
## 0.54.0
### Added
- WebSocket support.
- Testnet4 support.
## 0.53.11
### Changed
- Dummy version increase to signal upstream update of Haskoin Core.
## 0.53.10
### Fixed
- Correct test that was reversed in previous version.
## 0.53.9
### Removed
- Mempool is no longer synced by default to fix public Bitcoin Core regression.
## 0.53.8
### Changed
- Put derivations stat inside database.
## 0.53.7
### Added
- Added counters for database retrievals.
- Added counter for xpub derivations.
### Changed
- Removed some buggy or unnecessary stats.
## 0.53.6
### Changed
- Improve web server statistics.
## 0.53.5
### Addded
- Endpoint to delete an xpub from cache.
## 0.53.4
### Added
- Debugging when reverting block.
### Fixed
- Negative (headers - blocks) diff shown incorrectly.
- Infinite loop when removing a block's coinbase transaction.
## 0.53.3
### Added
- Blockchain.info endpoint: `q/pubkeyhash/:addr`.
- Blockchain.info endpoint: `q/getsentbyaddress/:addr`.
- Blockchain.info endpoint: `q/pubkeyaddr/:addr`.
- Configurable request body limit size.
## 0.53.2
### Fixed
- Return output in satoshi for some endpoints.
## 0.53.1
### Fixed
- Return 404 in case of bad address.
## 0.53.0
### Added
- Blockchain.info endpoint: `q/addresstohash/:addr`.
- Blockchain.info endpoint: `q/addrpubkey/:pubkey`.
- Blockchain.info endpoint: `q/hashpubkey/:pubkey`.
- Blockchain.info endpoint: `q/getblockcount`.
- Blockchain.info endpoint: `q/latesthash`.
- Blockchain.info endpoint: `q/bcperblock`.
- Blockchain.info endpoint: `q/txtotalbtcoutput/:txid`.
- Blockchain.info endpoint: `q/txtotalbtcinput/:txid`.
- Blockchain.info endpoint: `q/txfee/:txid`.
- Blockchain.info endpoint: `q/txresult/:txhash/:addr`.
- Blockchain.info endpoint: `q/getreceivedbyaddress/:addr`.
- Blockchain.info endpoint: `q/addressbalance/:addr`.
- Blockchain.info endpoint: `q/addressfirstseen/:addr`.
- Support xpubs in `blockchain/rawaddr` endpoint.
### Fixed
- Various latest blocks endpoint fixes.
- Allow empty parameters in Blockchain.info POST requests.
## 0.52.13
### Fixed
- Upstream fixes for unknown inv types.
## 0.52.12
### Fixed
- Fix limits for legacy endpoints.
## 0.52.11
### Added
- Alias for Blockchain.info raw address endpoint.
### Fixed
- Fix unknown message types without payload upstream.
- Randomise peer timeouts upstream.
## 0.52.10
### Fixed
- Fix binary search algorithm for blocks upstream.
## 0.52.9
### Added
- Add Blockchain.info latest block endpoint.
- Add Blockchain.info unconfirmed-transactions endpoint.
- Add Blockchain.info blocks for one day endpoint.
## 0.52.8
### Fixed
- Fix special case for zero limit.
## 0.52.7
### Fixed
- Fix cache bug when too many transactions in mempool.
## 0.52.6
### Changed
- Use rationals for Blockchain.info export-history endpoint arithmetics.
## 0.52.5
### Added
- Support for Blockchain.info export-history endpoint.
### Fixed
- Use strict bytestring decoder for HTTP API client.
## 0.52.4
### Fixed
- Use Base58 addresses by default in Blockchain.info balance querios.
## 0.52.3
### Fixed
- Errors should also contain CORS headers.
## 0.52.2
### Fixed
- Blockchain.info raw address limit should use `limit` parametre and not `n`.
## 0.52.1
### Changed
- Stream multiple transactions when requested.
### Fixed
- Fix missing unspent outputs.
## 0.52.0
### Changed
- Remove unnecessary performance optimisations.
### Fixed
- Reduce balance retrievals for xpubs.
- Hack UTXO ordering to avoid unwanted behaviours.
- Do not merge conduits when there are too many.
## 0.51.0
### Fixed
- Data type for RequestTooLarge was missing.
## 0.50.3
### Added
- Log HTTP request bodies.
### Removed
- Remove web request timeout.
### Fixed
- Do not ignore unknown start tx anchors in conduits.
- Use fast transaction counting in cache.
### Changed
- Use WAI middlewares to manage stats.
## 0.50.2
### Fixed
- Do not use lazy parsers for incoming data that may throw exceptions.
## 0.50.1
### Fixed
- Do not allow incoming POST requests of unlimited body size.
## 0.50.0
### Added
- Limit number of simultaneous xpubs being cached.
## 0.49.0
### Changed
- Improve conduit merging algorithm.
## 0.48.0
### Added
- Timeouts and token bucket for web requests.
- Configurable price fetch interval.
## 0.47.6
### Fixed
- Fix web.all stat.
## 0.47.5
### Changed
- Simplify stats.
## 0.47.4
### Added
- Implement Blockchain.info block height.
- Implement Blockchain.info raw address.
- Implement Blockchain.info balances.
### Fixed
- Make Blockchain.info unspent endpoint more efficient.
- Make Blockchain.info xpubs endpoint more efficient.
### Changed
- Use compact JSON serialization by default everywhere.
## 0.47.3
### Fixed
- Fix serialization bug with unspents.
## 0.47.2
### Fixed
- Fix serialization bug for health check.
## 0.47.1
### Fixed
- Fix serialization bugs for web data types.
## 0.47.0
### Added
- Support for legacy block endpoints.
### Changed
- Serialization now uses bytes library and does interleaved IO.
## 0.46.6
### Added
- Allow comma-separated values in multiaddr.
## 0.46.5
### Changed
- Throw error when offset exceeded instead of truncating it.
## 0.46.4
### Fixed
- Do not compute balances separately for loose addresses when part of an xpub.
### Changed
- Do not fetch entire transaction list for loose addresses.
- Transaction count in wallet object is just a synonym for filtered tx count.
- Use conduits to prevent over-fetching transactions from database.
## 0.46.3
### Fixed
- Make hex value encoding compatible with Java BigInteger decoder.
## 0.46.2
### Changed
- Allow negative confirmations for compatibility with old API.
## 0.46.1
### Added
- Filters for transactions in multiaddr endpoint.
## 0.46.0
### Fixed
- Release to fix unintentional upload.
## 0.45.0
### Added
- Using a tx_index that results in a txid conflict returns a 409 - Conflict.
## 0.44.0
### Changed
- Numeric txid now 53 bits long and doesn't return transactions when hashes collide.
## 0.43.1
### Fixed
- Do not overcount statistics.
## 0.43.0
### Changed
- Transaction index now simply encodes txid as a long number (sorry JS users).
## 0.42.4
### Changed
- Optimise encoding of JSON data for Blockchain.info API.
## 0.42.3
### Changed
- Narrow down the balance for transactions to onlyShow set.
## 0.42.2
### Changed
- Make unspent algorithm more efficient.
## 0.42.1
### Added
- Support for Blockchain.info API unspent endpoint.
### Fixed
- Fix RBF transactions on Blockchain.info API.
## 0.42.0
### Removed
- No more pruning of old mempool transactions.
## 0.41.4
### Fixed
- Correct error computing wallet balances.
## 0.41.3
### Changed
- Use whole active set when computing results for multiaddr.
- Compute correct count of transactions for wallet.
## 0.41.2
### Changed
- Caching mempool is not much slower when pruning, so reversing that change.
## 0.41.1
### Changed
- Only prune mempool every ten minutes or so.
## 0.41.0
### Removed
- No more cache eviction endpoint.
## 0.40.22
### Added
- More metrics for cache.
## 0.40.21
### Added
- Support HTTP GET for multiaddr endpoint.
## 0.40.20
### Added
- Prefix 'app.' in statsd when using Nomad variables.
## 0.40.19
### Added
- Statsd support and pleny of statistics.
### Removed
- Removed use of sync lock for importing xpubs in cache due to volume.
## 0.40.18
### Added
- New options to control cache lock retry count and delay.
### Changed
- Cache xpubs asyncrhonously.
- Mempool syncs fully every refresh cycle.
## 0.40.17
### Changed
- Delete more than 1000 xpubs from Redis if needed.
- Attempt to get lock ten times in order to index a new xpub.
## 0.40.16
### Fixed
- Fix best block not set.
## 0.40.15
### Fixed
- Do not update cache best block if it is higher.
## 0.40.14
### Fixed
- Always respond to cache pings to avoid getting stuck.
## 0.40.13
### Added
- Be more careful about importing blocks to the cache.
### Removed
- Reduce excessive cache logging.
## 0.40.12
### Fixed
- Correct bad arithmetics in cache cooldown.
## 0.40.11
### Added
- Debug log cache cooldown.
### Fixed
- Unlimited retry lock acquisition now works.
- Make locking tighter
## 0.40.10
### Changed
- Reduce the number of things that cache do when pinged.
## 0.40.9
### Fixed
- Avoid filling the cache actor mailbox with pings.
## 0.40.8
### Fixed
- Correct a typo in cache code.
## 0.40.7
### Changed
- Improve cache mempool sync algorithm.
## 0.40.6
### Changed
- Make cache cooldown a number.
## 0.40.5
### Added
- Log every non-successful query.
## 0.40.4
### Fixed
- Use Redis TTL for cache cooldown.
## 0.40.3
### Fixed
- Mempool no longer gets saved in cache when node is not in sync.
## 0.40.2
### Changed
- Change source of price data to https://blockchain.info/ticker.
## 0.40.1
### Removed
- Do not expose Paths_haskoin_store module explicitly.
## 0.40.0
### Added
- Blockchain.info API compatibility for multiaddr and rawtx endpoints.
### Changed
- Segwit fields are no longer omitted on incompatible networks.
## 0.39.0
### Changed
- Upgrade Haskoin Core to support higher version on witness addresses.
## 0.38.4
### Fixed
- Fix block search by timestamp.
## 0.38.3
### Changed
- Disable low latency garbage collector by default.
## 0.38.2
### Changed
- Use GHC 8.10 and its low latency garbage collector.
## 0.38.1
### Changed
- Optimise algorithm for fork safety check.
## 0.38.0
### Added
- Support for Bitcoin Cash hard fork.
## 0.37.5
### Added
- Configurable cache refresh time.
## 0.37.4
### Fixed
- Now request mempool when connecting even if already in sync.
### Changed
- Add a delay to mempool sync to allow for block headers to catch up.
- Attempt to sync mempool whenever syncing is done or a new peer connects.
## 0.37.3
### Changed
- Correct logic error when deleting superseded transactions.
## 0.37.2
### Changed
- Simplify multiple algorithms to hopefully solve corruption bug.
- Allow to disable mempool transaction indexing via command line.
## 0.37.1
### Changed
- Better locking around caching operations.
- Have a global cooldown on cache mempool updates.
### Fixed
- Fix address unspent retrieval using correct column family.
## 0.37.0
### Added
- Add support for column families and prefixes breaking database backwards compatibility.
## 0.36.2
### Fixed
- Fix another place where mempool sorting was wrong.
## 0.36.1
### Fixed
- Fix wrong sorting of mempool transactions in database.
## 0.36.0
### Changed
- Do not use STM transactions because it is impossible to reason about preloading.
- Make importing blocks after mempool is populated faster.
## 0.35.2
### Changed
- Reduce frequency of cache mempool updates.
## 0.35.1
### Changed
- Remove cache lock retries.
- Do not use lock when caching a new xpub.
## 0.35.0
### Changed
- Use new RocksDB Haskell bindings.
- Make headers - blocks diff configurable in health check.
- Simplify locking in cache.
## 0.34.8
### Changed
- Minor refactoring.
- Only send one mempool message ever.
## 0.34.7
### Changed
- Fix block heights endpoint URL.
## 0.34.6
### Removed
- Remove asynchronous database retrieval permanently due to instability.
## 0.34.5
### Added
- Preload memory before freeing outputs.
## 0.34.4
### Added
- Asynchronous preloading only for blocks.
## 0.34.3
### Removed
- Disable asynchronous preloading to prevent segmentation fault error.
## 0.34.2
### Removed
- No more upper limit for mempool call.
### Fixed
- Health check uses minimum between last block and mempool tx.
## 0.34.1
### Added
- Pending mempool transactions health check.
### Removed
- No more upper limit for mempool call.
## 0.34.0
### Changed
- New format for health check.
## 0.33.1
### Changed
- Upload with updated Cabal files.
## 0.33.0
### Fixed
- Fix outputs showing up as both spent and unspent.
### Changed
- Simplify data structures used to hold uncommitted changes.
- Split StoreRead class in two.
- Improve pre-loading algorithms.
## 0.32.3
### Fixed
- Fix command line argument mappings to env vars.
## 0.32.2
### Fixed
- Do not complain when deleting non-existent unconfirmed txs.
## 0.32.1
### Fixed
- Fix corruption bug when deleting transactions during some reorgs.
- Fix tests on data package.
- Rename upstream address string functions.
## 0.32.0
### Changed
- Concurrently load dependencies when importing transaction data.
- Import each transaction using STM.
- Rework logging.
- Refactor all block chain importing algorithms.
- Use peer locking when importing data.
- Change license to MIT.
### Added
- Make max peer count configurable.
### Fixed
- Prevent premature peer timeouts when importing blocks.
## 0.31.0
### Added
- Add Haskell web client code to data library.
- Use type-safe definitions for web paths and parameters.
- Support JSON pretty encoding and enable by default for some endpoints.
- Allow environment variables for configuration.
### Changed
- Change command-line arguments to better fit GNU style.
- Refactor code to manipulate address balances.
- Improve logging.
- Rate-limit mempool importing.
- Do not add xpubs to cache if node not in sync.
- Do not import transactions to cache if no xpubs in cache.
- Refactor transaction importing logic extremely.
- Refactor memory database and writer.
### Fixed
- Fix BTC double-count transaction bug.
- Add missing xpub derive parameter to xpub evict documentation.
## 0.30.1
### Changed
- Limit mempool API endpoint list.
## 0.30.0
### Changed
- Raw JSON values are now wrapped in an object with a result property.
- Better logging when importing transactions into mempool.
### Fixed
- Transaction limit by block height works now.
## 0.29.3
### Changed
- Revert concurrent retrieval changes from 0.29.1 and 0.29.0 to solve stability
issues.
- Bitcoin Cash (BCH) replaces BTC as default network in CLI.
- Peer discovery enabled automatically if no peers specified in CLI.
- Use separate Stack configuration file for data package.
## 0.29.2
### Changed
- Increase timeouts for manager and chain health checks.
## 0.29.1
### Added
- Perform xpub operations concurrently.
## 0.29.0
### Changed
- BlockTx renamed to TxRef.
- Remove unnecessary monad transformers to simplify import code.
### Added
- Retrieve balances and unspent outputs concurrently when importing.
- Coin instance for Unspent in data package.
## 0.28.0
### Changed
- Change the way that limits, start, and offset values are handled.
### Fixed
- Fix incorrect limit responses.
## 0.27.0
### Added
- Complete support for offset.
### Changed
- Improve monad stack for cache.
## 0.26.6
### Added
- Support for offset in all endpoints where it makes sense.
## 0.26.5
### Fixed
- Sort after using the nub function or use Data.List.nub in exceptional cases.
## 0.26.4
### Changed
- Don't do certain validity checks on confirmed transactions.
### Fixed
- Do not crash when syncing the blockchain from scratch on a populated cache.
## 0.26.3
### Changed
- Replace nub function everywhere with faster version written using hash sets.
### Fixed
- Fix shared cache locking.
## 0.26.2
### Changed
- Simplify cache block import code.
- Improve cache import performance.
## 0.26.1
### Fixed
- Do not call zadd or zrem in Redis with incorrect argument count.
### Changed
- Do not use slow Transaction type in Logic.
- Improve logging while importing blocks.
- Better transaction import algorithm.
## 0.26.0
### Changed
- Add information to some binary types for feature parity with JSON.
## 0.25.4
### Changed
- Hide segwit data on non-segwit networks.
### Fixed
- Fix work which now always serialises as a number literal.
## 0.25.3
### Changed
- Fix version display on health check.
## 0.25.2
### Changed
- Fix wrong version of Haskoin Store Data dependency.
## 0.25.1
### Changed
- Improve code organisation.
- Split data definitions and serialisation into its own package.
## 0.24.0
### Changed
- Use mocking to simulate peers instead of connecting to the network while testing.
- Depend on latest version of Haskoin Core for faster JSON serialisation.
- Clean up confusing JSON encoding/decoding codebase.
## 0.23.24
### Changed
- Implement faster JSON encoding using toEncoding from the Aeson library.
## 0.23.23
### Changed
- Do not read full mempool so often from cache code.
## 0.23.22
### Changed
- Depend on latest Haskoin Node that fixes debugging regression.
## 0.23.21
### Changed
- Reduce non-debug log verbosity.
## 0.23.20
### Changed
- Better Haskoin Node logging.
## 0.23.19
### Changed
- Use set peer timeout instead of constant in block store.
## 0.23.18
### Changed
- Allow setting peer timeouts in command line.
### Fixed
- Bump Haskoin Node dependency to fix another premature timeout condition.
## 0.23.17
### Fixed
- Touch syncing peer whenever we process one of its blocks to avoid premature timeout.
## 0.23.16
### Changed
- Better algorithm to avoid importing transaction multiple times in cache.
- Depend on latest Haskoin Node.
## 0.23.15
### Changed
- Do not storm the cache with mempool transactions.
## 0.23.13
### Fixed
- Do not ignore deleted incoming transactions.
## 0.23.12
### Fixed
- Do not do RBF checks when replacing a mempool transaction with a confirmed one.
## 0.23.11
### Fixed
- Streamline mempool transaction importing.
## 0.23.10
### Fixed
- Fix transactions not recorded in cache mempool set.
- Fix transactions being downloaded multiple times.
### Removed
- Do not store orphan transactions in database.
### Changed
- Use sets for incoming transactions instead of lists.
- Do not do anything to the cache if there are no xpubs in it.
## 0.23.9
### Fixed
- Wiping mempool fixed.
## 0.23.8
### Added
- Chunk transactions to be deleted from mempool.
## 0.23.7
### Added
- Mempool improvements.
## 0.23.6
### Added
- Ability to wipe mempool at start.
- Improvements to mempool processing code.
## 0.23.5
### Changed
- Tighten the locking loop to avoid slow cache building.
## 0.23.5
### Fixed
- Wrong error in cache when acquiring lock.
## 0.23.4
### Added
- Add extra debug logging for cache code.
### Fixed
- Fix a bug with xpub growing algorithm.
### Changed
- Use locks instead of transactions to update cache.
## 0.23.3
### Fixed
- Reduce contention when many instances of Haskoin Store share a cache.
## 0.23.2
### Added
- Allow retrieving xpub data without using cache.
## 0.23.1
### Added
- Allow xpub eviction from cache via API.
- Clarify cache address addition code.
### Fixed
- Balances were incorrectly computed in cache when new transactions arrived.
## 0.23.0
### Added
- Support for Redis transactions.
- Use a smaller initial gap for empty xpubs.
### Changed
- Remove custom JSON encoding class.
- Refactor and code simplification.
## 0.22.5
### Fixed
- Cache was being completely pruned.
## 0.22.4
### Fixed
- Cache now prunes correctly.
## 0.22.3
### Fixed
- Bug was making cache get stuck when pruning.
## 0.22.2
### Changed
- More efficient algorithms for caching and cache misses.
- Better debug logging of cache hits and misses.
## 0.22.1
### Added
- More debug logging for cache hits.
### Fixed
- Bug using maximum against empty list.
## 0.22.0
### Changed
- Extreme code refactoring.
- Move all code to Haskoin and drop Network from modules.
### Added
- Use Redis pipelining when importing multiple transactions into cache.
- Implement configurable LRU for Redis cache.
- Import xpubs directly into cache from web worker thread when a key is requested.
### Removed
- Only expose a few modules to external API.
## 0.21.7
### Changed
- Improve build configuration.
### Fixed
- Use minimum used addresses instead of minimum index for xpub cache decision.
## 0.21.6
### Fixed
- Fix missing xpub unspent outputs when using cache.
## 0.21.5
### Added
- Only store xpubs in cache if they have more than a threshold addresses used.
## 0.21.4
### Fixed
- Fix shared cache case where head is set beyond header chain by another node.
## 0.21.3
### Fixed
- Fix bug where best head was not being registered in cache.
- Fix best head in cache being decoded incorrectly.
## 0.21.2
### Added
- Complete support for Redis xpub cache.
## 0.21.1
### Fixed
- Latest version of secp256k1-haskell works with Debian 9.
## 0.21.0
### Fixed
- Fix output of web API calls when issuing limits with offsets.
### Changed
- Massive refactoring of entire codebase.
### Added
- Work in progress Redis caching for extended public keys.
## 0.20.2
### Changed
- Filter xpub address balances on web API to show only addresses that have been used.
### Removed
- Remove paths and addresses from xpub summary.
## 0.20.1
### Changed
- Refactor code greatly.
- Depend on new Haskoin Store package to avoid missing tx broadcasts.
- Merge StoreStream class into StoreRead.
- Move former streaming functions to use lists instead of conduits.
- Remove excessively verbose debugging.
## 0.20.0
### Added
- Set minimum version bounds for some dependencies.
- Now compatible with GHC 8.8.
- Extended key caching system using Redis.
### Changed
- Massively refactored codebase.
- Less verbose debug logging.
### Removed
- Removed conduits for faster queries.
## 0.19.6
### Added
- Use a parallel strategy to compute key derivations.
### Fixed
- Do not fail health check upon transaction timeout while syncing.
### Changed
- Do not use conduits for xpub balance streams.
- Multiple minor refactorings.
## 0.19.5
### Changed
- Minor refactor to block import code.
### Fixed
- Minor fix to transaction timeout check.
## 0.19.4
### Fixed
- Clarify and correct health check algorithm.
## 0.19.3
### Changed
- Add address transactions to cache.
- Improve multi-address transaction retrieval algorithms.
## 0.19.2
### Removed
- Cache-Control header turned out to be unnecessary.
### Fixed
- Fix some minor errors in web module.
## 0.19.1
### Added
- Set Cache-Control header to no-cache.
## 0.19.0
### Changed
- Store mempool in single key/value pair.
## 0.18.11
### Changed
- Do not stream mempool.
## 0.18.10
### Removed
- Disable timeout checks for testnets.
## 0.18.9
### Added
- Endpoint to locate a block by unix timestamp.
### Removed
- No more persistence for peers due to dependency on newest haskoin-node.
## 0.18.8
### Added
- Transaction and block timeouts for health check.
- Raw blocks.
## 0.18.7
### Fixed
- Missing tranasctions on xpub listings.
## 0.18.6
### Removed
- Follow Stack advise removing `-O2` GHC option.
## 0.18.5
### Added
- Compatibility with SegWit on extended public key endpoints.
### Changed
- Fix syncing peer not reset after timeout.
- Use simpler monad for streaming data.
## 0.18.4
### Changed
- Bump Haskoin Node to fix peers not stored and excessively verbose logging.
## 0.18.3
### Changed
- Configurable HTTP request logging. Disabled by default.
## 0.18.2
### Changed
- Fix for memory leak.
## 0.18.1
### Removed
- Remove transaction count from xpub summary object.
## 0.18.0
### Changed
- Simplified limits and start point handling on web API.
- Made transaction streaming algorithm faster for xpub transactions.
- Extended public key summary output contains all addresses that have received transactions.
### Added
- Fine-grained control for maximum limits via command line options.
- Transaction hash as starting point.
- Block hash as starting point.
- Timestamp as starting point.
- Configurable xpub gap limit.
- Transaction count added to xpub summary.
- UTXO count added to xpub summary.
### Removed
- Mempool endpoint now has no limits or offsets and always returns full list.
- Extended public key summary output no longer includes any transactions.
- Offsets not allowed for transaction lists involving multiple addresses or xpubs.
- Confusing block position parameter no longer part of web API.
## 0.17.2
### Changed
- Stream address balances and unspent outputs.
- Add configurable max value for limit and offset which defaults at 10000.
## 0.17.1
### Changed
- When posting a transaction to the network, timeout is now five seconds.
- Improve error message when transaction post timeout reached.
- Remove obsolete `not found` error for transaction post.
- Endpoints for retrieving blocks now do streaming for better performance.
- Improve Swagger API documentation.
## 0.17.0
### Added
- Endpoints for retrieving block transactions.
- Endpoint for retrieving set of latest blocks.
### Changed
- Use standardized JSON and binary serialization schemes for raw transaction endpoints.
## 0.16.6
### Changed
- Now logging info messages too by default.
- Consolidated web logging in middleware.
### Removed
- UUIDs for web requests.
## 0.16.5
### Removed
- Remove concurrency from xpub balance requests to prevent RocksDB segfaults.
## 0.16.4
### Removed
- Remove concurrency from requests using iterators to prevent RocksDB from segfaulting.
## 0.16.3
### Added
- Debugging information for web API.
## 0.16.2
### Changed
- Debugging disabled by default (use `--debug` to enable).
## 0.16.1
### Added
- Cache mempool transactions.
- Improve initial syncing performance.
## 0.16.0
### Added
- Orphan transaction support.
- Full address balance cache in RocksDB.
- Full unspent output cache in RocksDB.
### Changed
- Significantly refactor code.
- Move web stuff to its own module.
- Change types related to databases.
- Make xpub balance, transaction and unspent queries fetch data in parallel.
## 0.15.2
### Added
- Internal data types to support orphan transactions.
### Changed
- Do not spam block actor with pings.
- Fix balance/unspent cache not reverting when importing fails.
- Fix transaction sorting algorithm not including transaction position information.
- Fix conflicting mempool transaction preventing block from importing.
## 0.15.1
### Changed
- Fix duplicate coinbase transaction id bug.
## 0.15.0
### Removed
- Removed `PreciseUnixTime` data type.
### Changed
- Use 64 bits for Unix time representation.
- Data model now uses simplified Unix time representation.
## 0.14.9
### Added
- Last external/change index information to xpub summary object.
## 0.14.8
### Added
- Endpoint for xpub summaries.
- Endpoints for full transactions.
- Ability to query by offset/limit.
- More API documentation.
## 0.14.7
### Added
- Debug information for `publishTx`.
### Changed
- Transaction publishing no longer requests mempool.
- Fixed serialization for `TxId` freezing the entire program by infinitely recursing.
## 0.14.6
### Changed
- Enable full threading again as it was deemed not responsible for the freezing behaviour.
## 0.14.5
### Changed
- Enable threading but leave it at a single thread to be able to open more than 1024 files.
## 0.14.4
### Changed
- Target LTS Haskell 13.20 and disable threading in new attempt to fix freezing bug.
## 0.14.3
### Changed
- Remove `-O2`.
## 0.14.2
### Changed
- Target LTS Haskell 12.26 to attempt to fix freezing bug.
## 0.14.1
### Added
- Extra debugging around code that freezes.
### Changed
- Bump dependency on `haskoin-node`.
## 0.14.0
### Removed
- Dump slow protobuf serialization.
### Added
- Add custom serialization.
- Extra debug logging.
### Changed
- Bump `haskoin-core` and `haskoin-node`.
## 0.13.1
### Changed
- Bump `haskoin-node` in `stack.yaml`.
- Do not send empty `getdata` messages.
## 0.13.0
### Added
- Primitive content negotiation for web exceptions.
- Protobuf support for errors.
- Protobuf support for tranasction ids.
### Changed
- Protobuf format changed in non-backwards-compatible manner for transaction ids.
## 0.12.0
### Added
- Support for binary serialization using Protocol Buffers.
- New endpoints for binary raw transactions (not hex-encoded).
### Changed
- Services field now a hex string instead of a number to avoid overflowing signed 64-bit integer.
- Flatten list of block data objects when responding to request for multiple block heights.
- Errors now reported in plain text without container JSON object.
- Transaction broadcasts are responded to with transaction id in plaintext hex (no JSON).
- Remove database snapshots to improve performance.
## 0.11.2
### Changed
- Fix duplicate mempool transaction announcements in event stream.
## 0.11.1
### Removed
- Removed latest block time check.
## 0.11.0
### Changed
- Improve post transactions endpoint.
## 0.10.1
### Changed
- Fix bug where transaction lists from multiple addresses would sort incorrectly.
- Address gap reduced to 20.
## 0.10.0
### Removed
- Remove addresses from transaction lists.
- No longer use container objects for xpub transactions.
## 0.9.3
### Added
- Permissive CORS headers to allow queries from any domain.
- Improved documentation using real-world examples from the BCH testnet.
## 0.9.2
### Added
- HTTP JSON API switch to turn off transaction list when retrieving blocks.
## 0.9.1
### Added
- Total block fees.
- Total block outputs.
- Block subsidy.
### Changed
- Do not consider the blocks less one block away from headers as out of sync in health check.
- Health check now returns HTTP 503 when not OK or out of sync.
## 0.9.0
### Added
- Version to health check output.
- Block weight for segwit.
- Transaction weight for segwit.
## 0.8.1
### Added
- Health check endpoint.
## 0.8.0
### Added
- Limits and skips.
- Add timestamps to transactions.
- Add transaction count to address balance object.
- Add Merkle root to block data.
- Total funds received by an address now shows up in balance.
- Balances for any address that ever had funds show up in xpub endpoints.
### Changed
- Data model update.
- Performance improvement for xpub calls.
- Transactions are returned in reverse mempool/block order (highest or most recent first).
- Balance objects do not get deleted from database ever.
## 0.6.9
### Changed
- Reduce number of coinbase checks to 10,000 ancestors.
## 0.6.8
### Changed
- Further optimize coinbase after height checks.
## 0.6.7
### Changed
- Impose restrictions on recursion for coinbase after height checks.
## 0.6.6
### Added
- Check whether a transaction can be traced back to a coinbase after certain height.
## 0.6.5
### Changed
- Delete transactions in reverse topological order when reverting a block.
## 0.6.4
### Changed
- Do not fail silently when importing orphan transactions into the mempool.
## 0.6.3
### Changed
- Dummy release to bump haskoin-node in stack.yaml.
## 0.6.2
### Changed
- Correct bug where coinbase transactions weren't properly flagged.
## 0.6.1
### Changed
- Compatibility with Bitcoin Cash hard fork.
- Various bug fixes.
## 0.6.0
### Added
- Address balance cache in memory.
### Changed
- Simplify data model further.
- Fix bug importing outputs with UTXO cache.
- Unspent balances cannot be negative.
## 0.5.0
### Added
- Add UTXO cache in memory.
- Get transactions with witness data in segwit networks.
### Changed
- Paths for derivations in xpubs is a list and no longer a string.
- Various bug fixes.
## 0.4.2
### Removed
- Remove extended public key itself from output of relevant endpoints to save bandwidth.
## 0.4.1
### Changed
- Fix bug when deleting coinbase transactions.
- Extended public key API support.
## 0.4.0
### Changed
- Generate events for mempool transactions.
- Respond with entire block data when querying blocks by height.
## 0.3.1
### Changed
- Do not import transactions to mempool while not synced.
- Only sync mempool against a single peer.
- Allow duplicate transactions to fix re-introduced sync bug.
## 0.3.0
### Added
- Update dependencies.
- Keep orphan blocks and deleted transactions in database.
- Add a `mainchain` field for block data and a `deleted` field for transactions.
- Stream records for performance.
- Show witness data for transaction inputs in SegWit network.
- Support RBF in SegWit network.
### Changed
- Refactor all data access code away from actor.
- Refactor import logic away from actor.
- Abstract data access using typeclasses.
- Implement data access using clean layered architecture.
- Make most of import logic code pure.
- Database now in `db` as opposed to `blocks` directory.
- Use latest `haskoin-node`.
### Removed
- Remove some data from peer information output.
- Remove full transaction from address transaction data.
- Remove limits from address transaction data.
- Remove block data from previous output.
- Remove spender from JSON response when output not spent.
- Remove block hash from block reference.
## 0.2.3
### Removed
- Do not send transaction notifications if a block is being imported.
## 0.2.2
### Added
- Peer information endpoint.
### Changed
- Update `haskoin-node`.
## 0.2.1
### Changed
- Fix tests
## 0.2.0
### Added
- Documentation everywhere.
- Ability to retrieve address transactions.
### Changed
- New versions of NQE and Haskoin Node upstream.
- Improve and simplify API.
- Multi-element endpoints return arrays of arrays.
- Database snapshots for all queries are now mandatory.
### Removed
- Retrieving unspent and spent outputs for an address.
- Redundant API endpoints for multiple elements.
## 0.1.3
### Changed
- Fix a bug with transaction notifications.
- Improve handling orphan transactions.
## 0.1.2
### Changed
- Specify dependencies better.
## 0.1.1
### Changed
- Dependency `secp256k1` is now `secp256k1-haskell`.
## 0.1.0
### Added
- New `CHANGELOG.md` file.
- Bitcoin (BTC) and Bitcoin Cash (BCH) compatibility.
- RocksDB database.
- Mempool support.
- HTTP streaming for events.
- CashAddr support.
- Bech32 support.
- Rate limits.
### Changed
- Split out of former `haskoin` repository.
- Use hpack and `package.yaml`.
### Removed
- Removed Stylish Haskell configuration file.
- Remvoed `haskoin-core` and `haskoin-wallet` packages from this repository.