Coder Social home page Coder Social logo

fedorif / curl.lib.js Goto Github PK

View Code? Open in Web Editor NEW

This project forked from iotaledger/curl.lib.js

0.0 0.0 0.0 496 KB

IOTA Proof-of-Work algorithm ported to Javascript to work in WebGL2-enabled browsers

License: GNU General Public License v3.0

JavaScript 99.93% HTML 0.07%

curl.lib.js's Introduction

curl.lib.js

IOTA Proof-of-Work algorithm ported to Javascript to work in WebGL2-enabled browsers

build

npm install
npm run build

usage

An example of the usage of curl.lib.js:

var curl = require('curl.lib.js');
var myTryteString = 'FOOBAR9TRYTES';
var minWeight = 14;
curl.init();
curl.pow({trytes: myTryteString, minWeight})
    .then((nonce) =>{
        console.log(myTryteString.substr(0, 2187-81).concat(nonce));
    }).catch((error) => {
        /*
         woops. 
            maybe your trits were bad, 
            or your minWeightMagnitude was bad.
         Perhaps you need to take a long introspection,
         or just
         */
         console.log(error);
    });

Available functions:

  • init()
    • initializes the curl object. must be called before doing proof of work!
  • pow({trytes, minWeight})
    • gets the proof-of-work on a transaction
    • possible errors:
      • Webgl2 wasn't available
      • Transaction Trits were wrong length
      • Min Weight Magnitude was greater than Hash length (243)
  • setOffset(offset<int >0>)
    • sets an offset to start pow search from
    • useful for amortized proof of work
  • getHashCount()
    • returns the number of concurrent hash rows completed by this worker
  • interrupt(void)
    • interrupts the currently running proof-of-work function
  • resume(void)
    • continues the proof-of-work that you just interrupted
  • remove(void)
    • removes the proof-of-work job that you had previously queued
  • overrideAttachToTangle(iota)
    • overrides attachToTangle for iota.lib.js object

In Browser

Include dist/curl.min.js in your browser, and you'll find the curl object available in the window space.

To Do


  • Improve speed
    • Find out some way to perform iterative loops on Fragment Shader when each step needs to know the output of the last from a separate index (i,e. hacked-together compute shader).

curl.lib.js's People

Contributors

peterwilli avatar chrisdukakis avatar desjob avatar surjikal avatar paulhandy avatar olmul 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.