dcrd/blockchain/chaingen
Dave Collins bda174f38f
chaingen: Add spendable coinbase out snapshots.
This adds the ability to snapshot the current spendable coinbase output
state of the generator with a name and restore it later.  This will
allow more efficient tests to be created since they will be able to use
invalidation along with restoring the spendable outputs state to avoid
the need to go through the entire vote activation process multiple
times.
2021-08-27 14:09:04 -05:00
..
doc.go multi: replace godoc.org with pkg.go.dev 2020-02-18 19:35:19 -06:00
example_test.go multi: Start blockchain v4 module dev cycle. 2020-11-10 16:51:38 -06:00
generator.go chaingen: Add spendable coinbase out snapshots. 2021-08-27 14:09:04 -05:00
README.md multi: Update README.md files for go modules. 2021-01-22 14:39:23 -06:00

chaingen

Build Status ISC License Doc

Package chaingen provides facilities for generating a full chain of blocks.

Overview

Many consensus-related tests require a full chain of valid blocks with several pieces of contextual information such as versions and votes. Generating such a chain is not a trivial task due to things such as the fact that tickets must be purchased (at the correct ticket price), the appropriate winning votes must be cast (which implies keeping track of all live tickets and implementing the lottery selection algorithm), and all of the state-specific header fields such as the pool size and the proof-of-work and proof-of-stake difficulties must be set properly.

In order to simplify this complex process, this package provides a generator that keeps track of all of the necessary state and generates and solves blocks accordingly while allowing the caller to manipulate the blocks via munge functions.

Examples

  • Basic Usage Example
    Demonstrates creating a new generator instance and using it to generate the required first block and enough blocks to have mature coinbase outputs to work with along with asserting the generator state along the way.

Installation and Updating

This package is part of the github.com/decred/dcrd/blockchain/v3 module. Use the standard go tooling for working with modules to incorporate it.

License

Package chaingen is licensed under the copyfree ISC License.