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

@kyve/core

v1.3.5

Published

πŸš€ The base KYVE node implementation.

Downloads

202

Readme

Integrations

In order to archive data with KYVE protocol nodes have to run on a storage pool. Every protocol node runs on a runtime which defines how data is being retrieved and how data is being validated. A runtime is just the execution environment for a integration.

Creating a custom integration

Everybody can create a custom integration. For that it is highly recommended to use this package to ensure no unexpected behaviour occurs.

Installation

yarn add @kyve/core

Implement interface IRuntime

The interface IRuntime defines how a runtime needs to be implemented. It has three main methods which need to be implemented. Explanations in detail can be found on the interface itself in the form of comments (src/types/interfaces.ts).

An example implementation of the EVM runtime can be found here:

import { DataItem, IRuntime, Node } from "@kyve/core";
import { providers } from "ethers";

export default class EVM implements IRuntime {
  public name = "@kyve/evm";
  public version = "1.0.0";

  // get block with transactions by height
  public async getDataItem(core: Node, key: string): Promise<DataItem> {
    try {
      // setup web3 provider
      const provider = new providers.StaticJsonRpcProvider({
        url: core.poolConfig.rpc,
      });

      // fetch data item
      const value = await provider.getBlockWithTransactions(+key);

      // throw if data item is not available
      if (!value) throw new Error();

      // Delete the number of confirmations from a transaction to keep data deterministic.
      value.transactions.forEach(
        (tx: Partial<providers.TransactionResponse>) => delete tx.confirmations
      );

      return {
        key,
        value,
      };
    } catch (error) {
      throw error;
    }
  }

  // increment block height by 1
  public async getNextKey(key: string): Promise<string> {
    return (parseInt(key) + 1).toString();
  }

  // save only the hash of a block on KYVE chain
  public async formatValue(value: any): Promise<string> {
    return value.hash;
  }
}

Build your custom integration

Having the runtime implemented the final steps now are choosing suitable prebuild modules for your integration. There are three core features which need to be defined:

Storage Provider

The storage provider is basically the harddrive of KYVE. It saves all the data a bundle has and should be web 3 by nature. Current supported storage providers are:

Compression

The compression type should also be chosen carefully. Each bundle saved on the storage provider gets compressed and decompressed by this algorithm. Current supported compression types are:

  • NoCompression
  • Gzip (recommended)

Cache

The cache of an integration is responsible for precaching data, making data archival much faster. Current supported caches are:

  • JsonFileCache (recommended)

After settling on certain modules the integration can just be built together and started. An example from the EVM integration can be found here:

import { Node, Arweave, Gzip, JsonFileCache } from "@kyve/core";

import EVM from "./runtime";

new Node()
  .addRuntime(new EVM())
  .addStorageProvider(new Arweave())
  .addCompression(new Gzip())
  .addCache(new JsonFileCache())
  .start();

Contributing

To contribute to this repository please follow these steps:

  1. Clone the repository
    git clone [email protected]:KYVENetwork/core.git
  2. Install dependencies
    yarn install