{"id":50841049,"url":"https://github.com/tetherto/miningos-tpl-wrk-miner","last_synced_at":"2026-06-14T06:35:26.908Z","repository":{"id":344367302,"uuid":"1129676329","full_name":"tetherto/miningos-tpl-wrk-miner","owner":"tetherto","description":null,"archived":false,"fork":false,"pushed_at":"2026-05-02T10:01:08.000Z","size":252,"stargazers_count":0,"open_issues_count":0,"forks_count":5,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-05-02T12:06:12.023Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tetherto.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-01-07T12:28:49.000Z","updated_at":"2026-05-02T10:01:13.000Z","dependencies_parsed_at":"2026-05-02T12:03:06.249Z","dependency_job_id":null,"html_url":"https://github.com/tetherto/miningos-tpl-wrk-miner","commit_stats":null,"previous_names":["tetherto/miningos-tpl-wrk-miner"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/tetherto/miningos-tpl-wrk-miner","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tetherto%2Fminingos-tpl-wrk-miner","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tetherto%2Fminingos-tpl-wrk-miner/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tetherto%2Fminingos-tpl-wrk-miner/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tetherto%2Fminingos-tpl-wrk-miner/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tetherto","download_url":"https://codeload.github.com/tetherto/miningos-tpl-wrk-miner/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tetherto%2Fminingos-tpl-wrk-miner/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34312072,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-14T02:00:07.365Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-06-14T06:35:21.999Z","updated_at":"2026-06-14T06:35:26.903Z","avatar_url":"https://github.com/tetherto.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# miningos-tpl-wrk-miner\n\n## Table of Contents\n\n1. [Overview](#overview)\n2. [Architecture](#architecture)\n3. [Miner Worker Implementation](#miner-worker-implementation)\n\n## Overview\n\nThe miner worker system is built on a hierarchical class structure designed to manage and control mining devices in a distributed infrastructure. This documentation covers the abstract class hierarchy and key implementations for the miner worker system.\n\n## Architecture\n\nThe following is a fragment of [MiningOS object model](https://docs.mos.tether.io/) that contains the abstract class representing **Miner** (highlighted in blue). The rounded nodes reprsent abstract classes and the square nodes represent a concrete classes:\n\n```mermaid\n---\ntitle: Object Model of MiningOS\n---\nflowchart RL\n    bfx-wrk-base@{ shape: stadium, label: \"*bfx-wrk-base*\" }\n\n\n    tether-wrk-base@{ shape: stadium, label: \"*tether-wrk-base*\" }\n    tether-wrk-base---\u003ebfx-wrk-base\n\n\n    miningos-tlp-wrk-thing@{ shape: stadium, label: \"*miningos-tlp-wrk-thing*\" }\n    miningos-tlp-wrk-thing---\u003etether-wrk-base\n\n\n    miningos-tpl-wrk-miner@{ shape: stadium, label: \"*miningos-tpl-wrk-miner*\" }\n    miningos-tpl-wrk-miner---\u003eminingos-tlp-wrk-thing\n\n\n    miningos-wrk-miner-whatsminer[\"miningos-wrk-miner-whatsminer\"]\n    miningos-wrk-miner-whatsminer---\u003eminingos-tpl-wrk-miner\n\n    miningos-wrk-miner-antminer[\"miningos-wrk-miner-antminer\"]\n    miningos-wrk-miner-antminer---\u003eminingos-tpl-wrk-miner\n\n    miningos-wrk-miner-avalon[\"miningos-wrk-miner-avalon\"]\n    miningos-wrk-miner-avalon---\u003eminingos-tpl-wrk-miner\n\n\n    style miningos-tpl-wrk-miner fill:#005,stroke-width:4px,color:white\n```\n\nCheck out concrete implementations of Miner here:\n- [miningos-wrk-miner-avalon](https://github.com/tetherto/miningos-wrk-miner-avalon)\n- [miningos-wrk-miner-whatsminer](https://github.com/tetherto/miningos-wrk-miner-whatsminer)\n- [miningos-wrk-miner-antminer](https://github.com/tetherto/miningos-wrk-miner-antminer)\n\n#### Key Methods:\n- init(): Initializes storage and network facilities\n- getRpcKey(): Returns the RPC server public key\n- getRpcClientKey(): Returns the RPC client public key\n- _startRpcServer(): Starts the RPC server\n- _start(cb): Starts the worker with RPC endpoints\n\n#### Configuration:\n- Sets up storage directory based on environment\n- Configures logging with Pino\n- Initializes network facilities for RPC communication\n\n#### Methods to be overridden by children classes:\n- getThingType(): Returns the type of thing (e.g., 'miner')\n- getThingTags(): Returns default tags for the thing type\n- selectThingInfo(): Selects additional info to include in responses\n- collectThingSnap(thg): **(Must be overridden: original implementation throws error)** Collects a snapshot of the thing's current state\n- connectThing(thg): Establishes connection to the thing\n- disconnectThing(thg): Disconnects from the thing\n\n#### Lifecycle Hooks:\n- registerThingHook0(thg): Called when registering a new thing\n- updateThingHook0(thg, thgPrev): Called when updating a thing\n- forgetThingHook0(thg): Called when removing a thing\n- setupThingHook0(thg): Called during thing setup\n\n#### Core Features:\n\n##### Thing Management:\n- Registration: Add new devices to the system\n- Updates: Modify device configuration and info\n- Deletion: Remove devices from management\n- Querying: Search and filter devices\n\n##### Data Collection:\n- Periodic snapshot collection\n- Historical data logging (5-minute intervals)\n- Alert processing based on snapshots\n\n##### RPC Endpoints:\n- getRack: Get rack information\n- queryThing: Query individual thing methods\n- listThings: List all managed things\n- registerThing: Register new thing\n- updateThing: Update existing thing\n- forgetThings: Remove things\n- applyThings: Apply methods to multiple things\n- tailLog: Retrieve historical logs\n\n## Miner Worker Implementation\n\n### WrkMinerRack\n- **Source**: `rack.miner.wrk.js`\n- **Extends**: `WrkProcVar`\n- **Purpose**: Concrete implementation for managing mining devices\n\n#### Miner-Specific Features:\n\n##### IP Address Management:\n- Static IP assignment support\n- Dynamic IP allocation \n- IP release on device removal or maintenance\n\n##### Validation:\n- Prevents duplicate serial numbers\n- Prevents duplicate MAC addresses\n- Prevents duplicate container positions\n- Prevents duplicate IP addresses\n\n##### Miner Properties:\n```javascript\n{\n  opts: {\n    address: string,    // IP address\n    port: number,       // Connection port\n    forceSetIp: boolean // Force IP assignment\n  },\n  info: {\n    serialNum: string,  // Device serial number\n    macAddress: string, // Network MAC address\n    pos: string,        // Position in container\n    container: string,  // Container ID\n    location: string    // Physical location\n  }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftetherto%2Fminingos-tpl-wrk-miner","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftetherto%2Fminingos-tpl-wrk-miner","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftetherto%2Fminingos-tpl-wrk-miner/lists"}