Coder Social home page Coder Social logo

rust-hashgraph's Introduction

An implementation of the SWIRLDS HashGraph Consensus Algorithm as specified in the paper. This is a library that provides all the functions needed to reach consensus.

This code uses iterators to traverse commitments, and although it is a pretty abstraction, it can be slow. I re-implemented the library using conventional graph search algorithms and matrix math here. Performance is improved dramatically.

Interact in the browser

Force directed hashgraph

The library compiles to WebAssembly and can be invoked like a normal ES6 module. The www directory contains a javascript webapp to interactively build and visualize a hashgraph as a force directed graph in D3.js.

Tests

Right now tests aren't work as the interface has changed to support wasm

Run the tests with cargo test. The unit tests in the graph module are the necessary steps to order all events topologically according to the HashGraph algorithm.

Tests snapshot


The main.rs file contains the project binary. This is effectively an event loop that will

  1. Connect and discover peers over the mDNS protocol
  2. Upon receiving an event from a peer, update the in-memory graph, and pass the event onto another random peer
  3. Host an HTTP service that a user can upload new transactions to, which will be encoded into an event and passed to a random peer

TODO

  • Nodes send and receive events on gossip network with rust-libp2p
  • Graph traversal optimizations
  • Right now cloning strings is abundant to support the js/wasm cross-boundary. There should be workarounds for this, or at least a macro system to generate an optimized version for native.

rust-hashgraph's People

Contributors

jaybutera avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

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.