Coder Social home page Coder Social logo

pangwa / crust-smanager-1 Goto Github PK

View Code? Open in Web Editor NEW

This project forked from crustio/crust-smanager

0.0 2.0 0.0 995 KB

A storage manager integrated with Crust, IPFS and sWorker(storage inspector) of Crust protocol

Home Page: https://crust.network

License: Apache License 2.0

JavaScript 0.35% TypeScript 99.26% Dockerfile 0.39%

crust-smanager-1's Introduction

crust-smanager

sManager (Storage Manager) is a file picking bot which continuously picking and handling files from Crust Network. Node operators can customize this module to implement their own file handling strategy. sManager maintains a local database to help making decision on pulling files.

Local Database

The local database stores below information:

  1. File Records: The files metadata(tips, size, replicas count, expire time etc.) on Crust Network.
  2. File and Owner Relationship: sManager also maintains the relationship between a file and an on-chain account. This information will help making better pulling decision.
  3. Chain Metadata: e.g. the block and time on chain.
  4. Pin Records: The pin history of files.
  5. Cleanup Records: The files needs to removed from local filesystem, normally this is triggered when a file expires on Crust Network.

Checkout Db Schema for the schema details.

Components

sManager was designed to have serveral tasks running independently. Tasks are either scheduled by the block event or by configured intervals. Each task plays as an actor which consumes/produces some information and communicate with other tasks through the db or applicaion context.

sManager follows the Fails Early priciple which means it will shutdown on any unexpected error. To support this priciple, tasks are designed to be recoverable after application restarts.

Below are a list of components that sManager has implemented.

Indexers

Indexers extract information into the local database from various data sources. Currently sManager has implemented below indexers:

  1. Chain Database Indexer: indexes file records from the Crust Network on-chain database.
  2. Chain Event Indexer: indexes file records by listening latest chain event.
  3. Chain Time Indexer: a simple indexer which push the latest block height and it's timestamp to the config table.

Simple Tasks

Simple tasks are speciualized tasks which runs periodly. Currently sManager has implemented below tasks:

  1. Group Info Updater: Update sworker identity information from sworker api.
  2. Ipfs Gc: Schedule ipfs gc periodly.
  3. Telemetry Reporting: Report smanager statistics information to the telemetry server.
  4. Pull Scheduler: Schedule file pulling based on configured strategey.
  5. Seal Status Updater: Update sealing status periodly.
  6. File Retry Task: Retry pulling if possible.
  7. File Cleanup Task: Cleanup deleted files from local filesystem.

Usage

  1. Clone repo
git clone https://github.com/crustio/crust-smanager.git
  1. Installing It's recommended to use volta as the node version manager. Please follow the volta docs to install it.
cd crust-smanager && npm i
  1. Debug
npm run dev
  1. Run in Prod
npm run build
npm start

It's recommended to run sManager using Docker with the restart=always restart policy.

A daemon guard should be configured if you want to run sManager natively without docker. Tools like pm2 and nodemon could be used.

Configuration

Checkout smanager-config.example.json

crust-smanager-1's People

Contributors

badkk avatar lowentropybody avatar pangwa avatar yashirooooo avatar

Watchers

 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.