-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
669 additions
and
467 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
export namespace AbortSignals { | ||
|
||
export function timeout(delay: number, parent?: AbortSignal) { | ||
return merge(AbortSignal.timeout(delay), parent) | ||
} | ||
|
||
export function merge(a: AbortSignal, b?: AbortSignal) { | ||
if (b === undefined) | ||
return a | ||
|
||
const c = new AbortController() | ||
|
||
const onAbort = (reason?: unknown) => { | ||
c.abort(reason) | ||
|
||
a.removeEventListener("abort", onAbort) | ||
b.removeEventListener("abort", onAbort) | ||
} | ||
|
||
a.addEventListener("abort", onAbort, { passive: true }) | ||
b.addEventListener("abort", onAbort, { passive: true }) | ||
|
||
return c.signal | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { Circuit, TorClientDuplex, createPooledCircuit } from "@hazae41/echalote" | ||
import { Mutex } from "@hazae41/mutex" | ||
import { Pool, PoolParams } from "@hazae41/piscine" | ||
import { Ok, Result } from "@hazae41/result" | ||
|
||
export function createCircuitPool<TorPoolError>(tors: Mutex<Pool<TorClientDuplex, TorPoolError>>, params: PoolParams = {}) { | ||
const pool = new Mutex(new Pool<Circuit, Error | TorPoolError>(async (params) => { | ||
return await Result.unthrow(async t => { | ||
const { index, signal } = params | ||
|
||
const tor = await tors.inner.tryGet(index % tors.inner.capacity).then(r => r.throw(t)) | ||
const circuit = await tor.tryCreateAndExtendLoop(signal).then(r => r.throw(t)) | ||
|
||
return new Ok(createPooledCircuit(circuit, params)) | ||
}) | ||
}, params)) | ||
|
||
pool.inner.signal.addEventListener("abort", async (reason) => { | ||
tors.inner.abort(reason) | ||
|
||
return Ok.void() | ||
}, { passive: true, once: true }) | ||
|
||
tors.inner.signal.addEventListener("abort", async (reason) => { | ||
pool.inner.abort(reason) | ||
|
||
return Ok.void() | ||
}, { passive: true, once: true }) | ||
|
||
return pool | ||
} |
Oops, something went wrong.
c02ea9a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
brume-wallet – ./
brume-wallet.vercel.app
brume-wallet-orbitum.vercel.app
brume-wallet-git-main-orbitum.vercel.app
wallet.brume.money