@exodus/bitcoin-api 5.1.2 → 5.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,15 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [5.1.3](https://github.com/ExodusMovement/assets/compare/@exodus/bitcoin-api@5.1.2...@exodus/bitcoin-api@5.1.3) (2026-11-20)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **bitcoin:** bypass request queue for mempool broadcasts ([#9398](https://github.com/ExodusMovement/assets/issues/9398)) ([42bb75d](https://github.com/ExodusMovement/assets/commit/42bb75d6705186eade6c1fc1a0cc4fff694880fc))
12
+
13
+
14
+
6
15
  ## [5.1.2](https://github.com/ExodusMovement/assets/compare/@exodus/bitcoin-api@5.1.1...@exodus/bitcoin-api@5.1.2) (2026-11-19)
7
16
 
8
17
 
package/README.md CHANGED
@@ -22,10 +22,10 @@ Reads receiving HTTP 429 rejoin the end of the queue instead of immediately fail
22
22
 
23
23
  ## Mempool request scheduling
24
24
 
25
- At most two REST requests run concurrently, including body consumption, with at least 200 ms between starts. Reads queue FIFO, bounded to 100 entries and a 30-second wait including cooldown. Abort signals remove queued requests; expired or cancelled entries never dispatch later. Normal requests have a 30-second dispatch-time timeout including the body, respecting shorter caller timeouts. History scans submit two address batches at a time while retaining full address coverage; Insight concurrency is unchanged.
25
+ At most two REST reads run concurrently, including body consumption, with at least 200 ms between starts. Reads queue FIFO, bounded to 100 entries and a 30-second wait including cooldown. Abort signals remove queued requests; expired or cancelled entries never dispatch later. Normal requests have a 30-second dispatch-time timeout including the body, respecting shorter caller timeouts. History scans submit two address batches at a time while retaining full address coverage; Insight concurrency is unchanged.
26
26
 
27
- Broadcasts jump ahead of queued reads only when request capacity is available. Active requests and broadcasts waiting for pacing reserve the two request slots; when both slots are occupied or reserved, a new broadcast fails immediately with `MEMPOOL_REQUEST_BUSY` and `finalError`, without automatic retry or later dispatch. The read queue limit does not consume broadcast capacity. Accepted broadcasts preserve FIFO order and 200 ms pacing, with the original one-second queue deadline; expired broadcasts fail finally with `MEMPOOL_REQUEST_QUEUE_TIMEOUT`. Active requests remain uninterrupted. New and queued broadcasts bypass local cooldown and recovery waits. Broadcasts never become recovery probes, and their success does not release read cooldown. Dispatched broadcasts receiving 429 still establish read cooldown and fail without automatic replay.
27
+ Broadcasts dispatch directly without entering the read queue, waiting for pacing, or consuming read request slots. They bypass local cooldown and recovery waits even when both read slots are occupied or the read queue is full. They have no queue deadline or local concurrency limit. Broadcasts never become recovery probes, and their success does not release read cooldown. Broadcasts receiving HTTP 429 still establish read cooldown and fail without automatic replay.
28
28
 
29
- Queue and request deadlines apply per attempt. The send wrapper can retry one non-final broadcast failure after ten seconds, so pacing waits and network timeouts across both attempts can total about 72 seconds, excluding transaction preparation and post-failure checks. The broadcast client does not currently accept a caller cancellation signal; consumers should await the send result rather than assume an earlier UI timeout cancels it.
29
+ Request timeouts apply per attempt. The send wrapper can retry one non-final broadcast failure after ten seconds, so network timeouts across both attempts can total about 70 seconds, excluding transaction preparation and post-failure checks. The broadcast client does not currently accept a caller cancellation signal; consumers should await the send result rather than assume an earlier UI timeout cancels it.
30
30
 
31
- Recovery resumes paced traffic rather than a burst. This client budget is not a vendor quota and cannot guarantee freedom from rate limits or bans. The five-minute cap may permit requests earlier than the server requested; queues and cooldowns are not persisted or coordinated across processes.
31
+ Recovery resumes paced reads rather than a burst. This read budget is not a vendor quota and cannot guarantee freedom from rate limits or bans. The five-minute cap may permit requests earlier than the server requested; queues and cooldowns are not persisted or coordinated across processes.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exodus/bitcoin-api",
3
- "version": "5.1.2",
3
+ "version": "5.1.3",
4
4
  "description": "Bitcoin transaction and fee monitors, RPC with the blockchain node, other networking code.",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -60,5 +60,5 @@
60
60
  "type": "git",
61
61
  "url": "git+https://github.com/ExodusMovement/assets.git"
62
62
  },
63
- "gitHead": "9bf1912c78b942063d49b76a022f6f22f1287568"
63
+ "gitHead": "542f0821665b4771aeecab4ce2a2e9614a2515c1"
64
64
  }
@@ -4,7 +4,6 @@ const MAX_ACTIVE_REQUESTS = 2
4
4
  const REQUEST_INTERVAL_MS = 200
5
5
  const MAX_QUEUED_READS = 100
6
6
  const MAX_QUEUE_WAIT_MS = 30_000
7
- const MAX_BROADCAST_QUEUE_WAIT_MS = 1000
8
7
  const MAX_READ_RETRIES = 2
9
8
  const schedulersByOrigin = new Map()
10
9
 
@@ -34,17 +33,15 @@ const drain = (origin) => {
34
33
  clearTimeout(scheduler.wakeTimer)
35
34
  scheduler.wakeTimer = null
36
35
  const cooldown = scheduler.getCooldown?.()
37
- const broadcastIndex = scheduler.queue.findIndex((entry) => entry.isBroadcast)
38
- if (broadcastIndex === -1 && scheduler.queue.length > 0 && cooldown?.retryAt > Date.now()) {
36
+ if (scheduler.queue.length > 0 && cooldown?.retryAt > Date.now()) {
39
37
  scheduler.wakeTimer = setTimeout(() => drain(origin), cooldown.retryAt - Date.now())
40
38
  } else if (
41
39
  scheduler.active < MAX_ACTIVE_REQUESTS &&
42
40
  !scheduler.timer &&
43
- (broadcastIndex !== -1 || !cooldown?.recovering) &&
41
+ !cooldown?.recovering &&
44
42
  scheduler.queue.length > 0
45
43
  ) {
46
- // Give sends the next available slot without interrupting active requests.
47
- const [entry] = scheduler.queue.splice(broadcastIndex === -1 ? 0 : broadcastIndex, 1)
44
+ const entry = scheduler.queue.shift()
48
45
  entry.cleanup()
49
46
  scheduler.active++
50
47
  scheduler.timer = setTimeout(() => {
@@ -71,11 +68,7 @@ const drain = (origin) => {
71
68
 
72
69
  export const resumeMempoolRequests = (origin) => drain(origin)
73
70
 
74
- function enqueueMempoolRequest(
75
- origin,
76
- execute,
77
- { signal, isBroadcast = false, getCooldown, expiresAt }
78
- ) {
71
+ function enqueueMempoolRequest(origin, execute, { signal, getCooldown, expiresAt }) {
79
72
  if (signal?.aborted) return Promise.reject(createAbortError(signal))
80
73
  const maxWaitMs = expiresAt - Date.now()
81
74
  if (maxWaitMs <= 0) {
@@ -87,10 +80,7 @@ function enqueueMempoolRequest(
87
80
  schedulersByOrigin.set(origin, scheduler)
88
81
  }
89
82
 
90
- const queuedCount = scheduler.queue.filter((entry) => entry.isBroadcast === isBroadcast).length
91
- // Broadcasts can wait for pacing, but never for an occupied request slot.
92
- const queueLimit = isBroadcast ? MAX_ACTIVE_REQUESTS - scheduler.active : MAX_QUEUED_READS
93
- if (queuedCount >= queueLimit) {
83
+ if (scheduler.queue.length >= MAX_QUEUED_READS) {
94
84
  return Promise.reject(createQueueError('MEMPOOL_REQUEST_BUSY'))
95
85
  }
96
86
 
@@ -100,7 +90,6 @@ function enqueueMempoolRequest(
100
90
  resolve,
101
91
  reject,
102
92
  expiresAt,
103
- isBroadcast,
104
93
  cleanup: () => {
105
94
  clearTimeout(timeout)
106
95
  signal?.removeEventListener('abort', onAbort)
@@ -129,13 +118,18 @@ function enqueueMempoolRequest(
129
118
  }
130
119
 
131
120
  export default async function scheduleMempoolRequest(origin, execute, options = {}) {
132
- const expiresAt =
133
- Date.now() + (options.isBroadcast ? MAX_BROADCAST_QUEUE_WAIT_MS : MAX_QUEUE_WAIT_MS)
121
+ if (options.isBroadcast) {
122
+ if (options.signal?.aborted) throw createAbortError(options.signal)
123
+ // Broadcast immediately, independently of read capacity, pacing, and recovery.
124
+ return execute()
125
+ }
126
+
127
+ const expiresAt = Date.now() + MAX_QUEUE_WAIT_MS
134
128
  for (let attempt = 0; ; attempt++) {
135
129
  try {
136
130
  return await enqueueMempoolRequest(origin, execute, { ...options, expiresAt })
137
131
  } catch (error) {
138
- if (options.isBroadcast || error?.code !== '429' || attempt >= MAX_READ_RETRIES) throw error
132
+ if (error?.code !== '429' || attempt >= MAX_READ_RETRIES) throw error
139
133
  }
140
134
  }
141
135
  }