53 releases (35 breaking)

0.44.0 Sep 26, 2024
0.43.0 Jul 18, 2024
0.41.0 Jul 12, 2024
0.36.0 Mar 18, 2024
0.8.0-alpha.5 Mar 24, 2020

#3 in #pow

Download history 34/week @ 2024-06-25 93/week @ 2024-07-09 113/week @ 2024-07-16 6/week @ 2024-07-23 3/week @ 2024-07-30 1/week @ 2024-08-20 8/week @ 2024-08-27 22/week @ 2024-09-10 8/week @ 2024-09-17 155/week @ 2024-09-24 56/week @ 2024-10-01 10/week @ 2024-10-08

248 downloads per month
Used in polkadot-sdk

GPL-3.0-or-later…

1MB
19K 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

Release

Polkadot SDK stable2409

Dependencies

~92MB
~2M SLoC