Git Product home page Git Product logo

hypercore-wasm-experiments's Introduction

hypercore-protocol in WASM through Rust

This is a first experiment to compile the Rust implementation of hypercore-protocol to WASM for use in browsers. At the moment, this is a minimal demo that only includes the wire protocol part (with all transport crypto) but not the persistence and verification parts (i.e. the hypercore crate).

  • Update 2021-03-03: Cleaned the code and fixed README
  • Update 2021-03-02: I wrote this some time back, now updated it roughly to the current dev branch of hypercore-protocol-rs. and pushed it to share and invite others to experiment with this

What this does (in Rust compiled to WASM):

  • Fetch a key, encoded as hex string, from /key
  • Open a Websocket to localhost:9000
  • Open a hypercore-protocol stream on the websocket
  • Open a channel for the key that was fetched before
  • Load all data blocks, and display them on the page (as a string in a pre element)

A Node.js server has the simple demo backend:

  • Create a hypercore feed in-memory
  • Append the contents of this README file
  • Open an HTTP server
  • On /key send the hypercore's key as a hex string
  • Serve the static files (index.html, index.js from this dir plus the WASM created through wasm-pack in /pkg)
  • On other requests, open a websocket connection and pipe it to the replication stream of the hypercore

How to run

cargo build
wasm-pack build --dev --target web
cd server
yarn
node server.js
# open http://localhost:9000

If it works, this should display this README in the browser, loaded over hypercore-protocol in Rust in WASM :-)

Check the browser console for some logs. It currently needs quite a while until the content is displayed, I don't know yet why this is.

hypercore-wasm-experiments's People

Contributors

frando avatar

Stargazers

 avatar Kaleb avatar Aza K9 avatar Martin Toman avatar Mac Cowell avatar Doug A avatar Morgan Moskalyk avatar Bendik Aagaard Lynghaug avatar Martín Acosta avatar Nina Breznik avatar Aswin avatar  avatar Matthew avatar Andrew Chou avatar Rik avatar

Watchers

 avatar James Cloos avatar

hypercore-wasm-experiments's Issues

Build failure: failed to select a version for the requirement `stream-cipher = "^0.3"`

Running cargo build results in the following error:

$ cargo build
    Updating crates.io index
    Updating git repository `https://github.com/datrs/hypercore-protocol-rs.git`
error: failed to select a version for the requirement `stream-cipher = "^0.3"`
candidate versions found which didn't match: 0.99.99, 0.7.1, 0.6.0, ...
location searched: crates.io index
required by package `salsa20 v0.4.0`
    ... which is depended on by `hypercore-protocol v0.1.0 (https://github.com/datrs/hypercore-protocol-rs.git?branch=reduce-async#f7caa04d)`
    ... which is depended on by `hypercore-rs-wasm v0.1.0 (/media/arnazeh/two/code/play/hypercore-wasm-experiments)`

Cargo --version: cargo 1.50.0 (f04e7fab7 2021-02-04)
OS: Pop!_OS 21.04

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.