gundb

Crates.iogundb
lib.rsgundb
version0.2.1
sourcesrc
created_at2022-01-21 15:29:24.138237
updated_at2022-05-16 11:06:35.384836
descriptionDistributed graph database that syncs over websockets and multicast
homepage
repositoryhttps://github.com/mmalmi/gun-rs
max_upload_size
id518596
size31,283,204
Martti Malmi (mmalmi)

documentation

README

Gun-rs

Pure Rust implementation of Gun.js. For a wasm version, check out gun-rs-wasm.

Iris-messenger uses the gun-rs node at wss://gun-rs.iris.to/gun

Why?

  • Rust can be compiled into high-performing native binaries on many platforms, including embedded systems.
  • Maintaining and contributing to the codebase is easier than in Gun.js. Gun.js doesn't have compilation or minification steps, and the code is kind of manually minified 😄

Use

Install Rust first.

Gun relay

cargo install gundb
gundb start

Gun library

use gundb::{Node, NodeConfig};
use gundb::types::GunValue;
let mut db = Node::new_with_config(NodeConfig {
    outgoing_websocket_peers: vec!["wss://some-server-to-sync.with/gun".to_string()],
    ..NodeConfig::default()
});
let mut sub = db.get("greeting").on();
db.get("greeting").put("Hello World!".into());
if let GunValue::Text(str) = sub.recv().await.unwrap() {
    assert_eq!(&str, "Hello World!");
}

Status

15/5/2022:

  • Gun basic API
  • CLI for running the server
  • Incoming websockets
  • Outgoing websockets (env PEERS=wss://some-server-url.herokuapp.com/gun)
  • Multicast (currently size limited to 65KB — large photos in messages will not sync over it)
  • In-memory storage
  • TLS support (env CERT_PATH and KEY_PATH)
  • Advanced deduplication of network messages
  • Publish & subscribe (network messages only relayed to relevant peers)
  • Disk storage (sled.rs)
  • Hash verification for content-addressed data (db.get('#').get(data_hash).put(data))
  • Signature verification of user data (db.get('~' + pubkey).get('profile') ...)
  • Encryption & decryption (usually done on the client side in js, like iris private messaging)

Issues

  • Multicast doesn't relay large messages like Iris posts with photos

Develop

cargo install cargo-watch
RUST_LOG=debug cargo watch -x 'run -- start'

Run on Heroku

heroku create --buildpack emk/rust
git push heroku master

or:

Deploy

Commit count: 228

cargo fmt