| 195 | } |
| 196 | |
| 197 | async getCount() { |
| 198 | const controller = new AbortController(); |
| 199 | const timeout = setTimeout(() => { |
| 200 | controller.abort(); |
| 201 | }, 1000); |
| 202 | const req = await fetch(`${this.httpurl}/count`, { |
| 203 | signal: controller.signal, |
| 204 | headers: this.auth |
| 205 | ? { |
| 206 | authentication: this.auth, |
| 207 | } |
| 208 | : undefined, |
| 209 | }); |
| 210 | clearTimeout(timeout); |
| 211 | if (req.status !== 200) return -1; |
| 212 | const res = Number.parseInt(await req.text()); |
| 213 | return res; |
| 214 | } |
| 215 | |
| 216 | do<T>(op: number, id: bigint, data: Buffer): Promise<T> { |
| 217 | const buf = Buffer.alloc(1 + 2); |