npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

blockchains.js

v1.0.3

Published

blockchains.js

Downloads

8

Readme

blockchains.js

Easy to use implementation of blockchains that allows you to store/validate data using NodeJS with high integrity. Save any object/string to blocks in the blockchain. Automatically saves and reloads your blockchains and chain validation at each initialization. Store your blockchain using your own unique encryption key. Allows setting block difficulty to increase security. Utilizes multithreading for difficult hashes. Store and run multiple chains at the same time with different difficulty levels.

Handles multiple block creations in a que, first-in-first-out, fashion to ensure that blocks occur in the order they are started regardless of the time it takes to hash the values. This functionality leaves the working process open due to a setTimeout on Blockchain.queTimeout. After all blocks have been created you can call process.exit() or clearTimeout(Blockchain.queTimeout) to stop the infinite loop that is checking if there are new blocks to hash.

Installation:

npm i blockchains.js yarn add blockchains.js

USAGE

You can test that everything is working by running a test script:

require('blockchains.js/test')

Or test that everything is working by running a test script:

process.env.DBPATH = './chains' //SET THE FOLDER WHERE YOU WANT CHAINS TO BE STORED - defaults to ./database const Blockchain = require('blockchains.js') const blockchain = new Blockchain('level-3', 3) // new Blockchain(chainName, chainDifficulty, encryptionkey) const saveBlock = async (data) => { console.log('hashing/adding block with data:', data) let block = await blockchain.addBlock(data) console.log('new block:', block) /* { index: 0, timestamp: 1649446340824, data: {data: 'test'}, previous: '', nonce: 1649447320193, hash: '000rXzsO35adrmEsShn4LX+mE1USI6pPsve5PKv6UBA=' }

    clearTimeout(blockchain.queTimeout) // use this code or process.exit() after everything is done to stop the process.
*/

} saveBlock({ data: 'test' })

Press control C to stop the process running or add clearTimeout(Blockchain.queTimeout) after all code has completed in your script or just do process.exit().

OBJECT STRUCTURE:

Block: { index, timestamp, data, previous, nonce, hash, _id, _t }

Blockchain.chain : Chain { chain: db { data: [Blocks] } length: number que: [function => Promise] queTimeout: setTimeout || null }

METHODS:

Blockchain.addBlock(data) => Promise => Block Blockchain.getLatestBlock() => Block || null Blockchain.validateChain() = true || false Blockchain.validBlock(block) => true || false Blockchan.manageQue() => null Blockchain.chain: push(data) => null at(index) => Block || null chain: find(function || object) => Promise => Block || null findAll(function || object) => Promise => [Blocks]