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

blockgraph

v1.0.2

Published

BlockTree is a novel implementation of a blockchain that, rather than forming a linear chain of blocks, forms a tree of blocks, with each block having an arbitrary number of child blocks. This enables more flexible, creative, and participatory processes,

Downloads

4

Readme

BlockTree

BlockTree is a novel implementation of a blockchain that, rather than forming a linear chain of blocks, forms a tree of blocks, with each block having an arbitrary number of child blocks. This enables more flexible, creative, and participatory processes, as any block can be extended with new content.

Overview

Unlike traditional blockchain implementations, which require a consensus mechanism to determine the order of blocks, BlockTree uses a locally validated and passively synchronized model. Each block is identified by a unique UUID, ensuring that blocks can be correctly and uniquely identified, regardless of the order in which they are created or received.

Getting Started

To install BlockTree, clone the repository and install the dependencies:

git clone https://github.com/username/BlockTree.git
cd BlockTree
npm install

how to use

// Create a new BlockTree instance
const blockTree = new BlockTree([]);

// Create a new transaction for the first block
const newBlockData1Transaction = new Transaction(
  TransactionType.ADD,
  new TransactionPayload(0, undefined, "ok")
);

// Create data for the first block
const newBlockData1 = new BlockData(
  "add first block",
  [newBlockData1Transaction],
  "Laodeus"
);

// Add the first block to the BlockTree
blockTree.addBlock("", newBlockData1);

// Log the BlockTree
console.log(JSON.stringify(blockTree));

Interfaces

IBlock

| Property | Type | Description | | -------- | ---- | ----------- | | id | string | The UUID of the block in the tree. | | hash | string | The hash of the block. | | previousHash | string | The hash of the previous block in the chain. | | data | IBlockData | The data associated with the block. |

Methods

| Method | Returns | Description | | ------ | ------- | ----------- | | calculateHash() | string | Calculates the hash for the block. | | validate() | boolean | Validates the block. |

IBlockData

| Property | Type | Description | | -------- | ---- | ----------- | | title | string | The title of the block. | | transaction | ITransaction[] | An array of transactions associated with the block. | | author | string | The author of the block. | | timestamp | string | The timestamp when the block was created. |

IBlockTree

| Property | Type | Description | | -------- | ---- | ----------- | | genesisBlock | IBlock | The first block in the blocktree. | | blockList | IBlock[] | A list of all blocks in the blocktree. |

Methods

| Method | Parameters | Returns | Description | | ------ | ---------- | ------- | ----------- | | addBlock(parentId: string, blockData: IBlockData) | parentId: string, blockData: IBlockData | IBlock | Adds a block to the blocktree. | | getBlockById(id: string) | id: string | IBlock | null | Gets a specific block by its ID. | | verifyIntegrity() | none | boolean | Verifies the integrity of the blocktree. | | getBlockChainToGenesis(blockId: string) | blockId: string | IBlock[] | Gets the chain of blocks from a specified block to the genesis block. | | getAllKnownChildren(blockId: string) | blockId: string | IBlock[] | null | Gets all known children of a specified block. | | synchronize(otherBlockTrees: IBlockTree[]) | otherBlockTrees: IBlockTree[] | void | Synchronizes the blocktree with other blocktrees. | | getGenesis() | none | IBlock | Returns the genesis block. |

ITransaction

| Property | Type | Description | | -------- | ---- | ----------- | | type | TransactionType | The type of the transaction. | | payload | ITransactionPayload | The details of the transaction. |

ITransactionPayload

| Property | Type | Description | | -------- | ---- | ----------- | | startIndex | number | The start index for the transaction operation. | | length | number (optional) | The length of the section to be affected by the transaction. | | content | string (optional) | The content to be added by the transaction. |root │

File Structure

├── models
│   ├── Block.ts
│   ├── BlockData.ts
│   ├── BlockTree.ts
│   ├── Transaction.ts
│   ├── TransactionPayload.ts
│   ├── Interfaces
│   │   ├── IBlock.ts
│   │   ├── IBlockData.ts
│   │   ├── IBlockTree.ts
│   │   ├── ITransaction.ts
│   │   ├── ITransactionPayload.ts
│   │   └── index.ts
│   └── index.ts
└── index.ts