29 releases (16 breaking)

0.24.0 Mar 5, 2023
0.22.0 Feb 19, 2023
0.15.0 Dec 21, 2022
0.9.0 Feb 10, 2021
0.8.0-alpha.5 Mar 24, 2020

#846 in Magic Beans

Download history 39/week @ 2022-12-01 101/week @ 2022-12-08 165/week @ 2022-12-15 60/week @ 2022-12-22 49/week @ 2022-12-29 52/week @ 2023-01-05 61/week @ 2023-01-12 85/week @ 2023-01-19 72/week @ 2023-01-26 97/week @ 2023-02-02 87/week @ 2023-02-09 137/week @ 2023-02-16 47/week @ 2023-02-23 47/week @ 2023-03-02 65/week @ 2023-03-09 82/week @ 2023-03-16

254 downloads per month


16K SLoC

Proof of work consensus for Substrate.

To use this engine, you can need to have a struct that implements PowAlgorithm. After that, pass an instance of the struct, along with other necessary client references to import_queue to setup the queue.

This library also comes with an async mining worker, which can be started via the start_mining_worker function. It returns a worker handle together with a future. The future must be pulled. Through the worker handle, you can pull the metadata needed to start the mining process via MiningWorker::metadata, and then do the actual mining on a standalone thread. Finally, when a seal is found, call MiningWorker::submit to build the block.

The auxiliary storage for PoW engine only stores the total difficulty. For other storage requirements for particular PoW algorithm (such as the actual difficulty for each particular blocks), you can take a client reference in your PowAlgorithm implementation, and use a separate prefix for the auxiliary storage. It is also possible to just use the runtime as the storage, but it is not recommended as it won't work well with light clients.

License: GPL-3.0-or-later WITH Classpath-exception-2.0


~1M SLoC