Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implementation #1

Open
kungfuflex opened this issue Feb 26, 2024 · 0 comments
Open

Implementation #1

kungfuflex opened this issue Feb 26, 2024 · 0 comments
Assignees

Comments

@kungfuflex
Copy link

Should expose the same JSON-RPC interface as metashrew-view as defined here:

https://github.com/sandshrewmetaprotocols/metashrew-view/blob/master/src.ts/metashrew-view.ts#L190

Should support environment variables

METASHREW_VIEW_INDEXER
METASHREW_VIEW_DB
METASHREW_VIEW_PORT
METASHREW_VIEW_HOST

which should point to a wasm file or a rockdb directory, respectively.

Should be able to pass in the following flags:

--indexer/-i
--db-dir/-d
--listen-addr/-a
--listen-port/-p

Which override anything set in the environment.

Should emit an error if any flags are missing, but address and port default to 127.0.0.1 and 3000 respectively.

Should launch an HTTP JSON-RPC service (no SSL for now) that binds to the supplied host and port. JSON-RPC should be built with jsonrpsee.

Event loop should be tokio. There should be no blocking code. This service will have to handle many concurrent requests.

Should open rocksdb in read-only mode for each RPC call. rocksdb gives the context a snapshot of when it was opened when the read-only handle is created. Import metashrew-runtime to invoke runtime with a no-op for __flush. WASM program should be invoked at the specified function with supplied input.

Refer to https://github.com/sandshrewmetaprotocols/metashrew/blob/master/src/electrum.rs#L227 to see how view functions are invoked now.

Result of JSON-RPC call should be consistent with what metashrew-view does. i.e. it should just return a { id, result, jsonrpc: '2.0' } JSON object where result is a hex encoded string.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants