Skip to main content

ckb_miner/
lib.rs

1//! Miner implementation for CKB block mining.
2//!
3//! This crate provides mining functionality including block template generation,
4//! proof-of-work verification, and worker management for the CKB blockchain.
5mod client;
6mod miner;
7mod worker;
8
9pub use crate::client::Client;
10pub use crate::miner::Miner;
11
12use ckb_jsonrpc_types::BlockTemplate;
13use ckb_types::packed::Block;
14use std::convert::From;
15
16/// Mining work unit containing a block template and work ID.
17#[derive(Clone)]
18pub struct Work {
19    /// Unique identifier for this work unit.
20    work_id: u64,
21    /// The block to be mined.
22    block: Block,
23}
24
25impl From<BlockTemplate> for Work {
26    fn from(block_template: BlockTemplate) -> Work {
27        let work_id = block_template.work_id;
28        let block: Block = block_template.into();
29
30        Work {
31            work_id: work_id.into(),
32            block,
33        }
34    }
35}