neutrino icon indicating copy to clipboard operation
neutrino copied to clipboard

Add Browser Support

Open linden opened this issue 1 year ago • 12 comments

This PR adds support for the browser using indexeddb as a storage backend for headerfs instead of the file system.

Why IndexedDB?

I'd initially chosen to go with localStorage for simplicity but due to recent rate limiting changes it made syncing past a couple 100 blocks freeze, indexddb does not have share these limitations. I'd also looked into emulating the file system but it turned out to add a lot of complexity with a performance loss over just using indexeddb directly.

Browser Testing.

Since Go only provides an executor for your native platform testing needs to be done via a custom executor targeting the browser. I've written my own called wasmexec which also provides file system access for ease of testing, you can run tests via the following:

# install wasmexec from the add-file-system branch while #1 is in progress.
go install github.com/linden/wasmexec@add-file-system

# target javascript/wasm and execute via wasmexec.
GOOS=js GOARCH=wasm go test -exec wasmexec ./...

I'm planning on provider this as part of a Github Action in the future.

btcd Changes.

Running this in the browser without wasmexec's file system access requires a couple of changes to btcd's addrmgr & btcutil as they require a file system. Changes made in https://github.com/btcsuite/btcd/pull/2124.

linden avatar Feb 18 '24 23:02 linden

@linden, remember to re-request review from reviewers when ready

lightninglabs-deploy avatar Aug 14 '24 00:08 lightninglabs-deploy

Closing due to inactivity

lightninglabs-deploy avatar Aug 19 '24 00:08 lightninglabs-deploy

Closing due to inactivity

lightninglabs-deploy avatar Aug 19 '24 01:08 lightninglabs-deploy

Closing due to inactivity

lightninglabs-deploy avatar Aug 19 '24 02:08 lightninglabs-deploy

Closing due to inactivity

lightninglabs-deploy avatar Aug 19 '24 03:08 lightninglabs-deploy

Closing due to inactivity

lightninglabs-deploy avatar Aug 19 '24 04:08 lightninglabs-deploy

Closing due to inactivity

lightninglabs-deploy avatar Aug 19 '24 05:08 lightninglabs-deploy

Closing due to inactivity

lightninglabs-deploy avatar Aug 19 '24 06:08 lightninglabs-deploy

Closing due to inactivity

lightninglabs-deploy avatar Aug 19 '24 07:08 lightninglabs-deploy

Closing due to inactivity

lightninglabs-deploy avatar Aug 19 '24 08:08 lightninglabs-deploy

Closing due to inactivity

lightninglabs-deploy avatar Aug 19 '24 10:08 lightninglabs-deploy

!lightninglabs-deploy mute

guggero avatar Aug 19 '24 10:08 guggero