lbcd/mining
Dave Collins 296fa0a5a0
blockchain: Convert to full block index in mem.
This reworks the block index code such that it loads all of the headers
in the main chain at startup and constructs the full block index
accordingly.

Since the full index from the current best tip all the way back to the
genesis block is now guaranteed to be in memory, this also removes all
code related to dynamically loading the nodes and updates some of the
logic to take advantage of the fact traversing the block index can
longer potentially fail.  There are also more optimizations and
simplifications that can be made in the future as a result of this.

Due to removing all of the extra overhead of tracking the dynamic state,
and ensuring the block node structs are aligned to eliminate extra
padding, the end result of a fully populated block index now takes quite
a bit less memory than the previous dynamically loaded version.

The main downside is that it now takes a while to start whereas it was
nearly instant before, however, it is much better to provide more
efficient runtime operation since that is its ultimate purpose and the
benefits far outweigh this downside.

Some benefits are:

- Since every block node is in memory, the recent code which
  reconstructs headers from block nodes means that all headers can
  always be served from memory which is important since the majority of
  the network has moved to header-based semantics
- Several of the error paths can be removed since they are no longer
  necessary
- It is no longer expensive to calculate CSV sequence locks or median
  times of blocks way in the past
- It will be possible to create much more efficient iteration and
  simplified views of the overall index
- The entire threshold state database cache can be removed since it is
  cheap to construct it from the full block index as needed

An overview of the logic changes are as follows:

- Move AncestorNode from blockIndex to blockNode and greatly simplify
  since it no longer has to deal with the possibility of dynamically
  loading nodes and related failures
- Rename RelativeNode to RelativeAncestor, move to blockNode, and
  redefine in terms of AncestorNode
- Move CalcPastMedianTime from blockIndex to blockNode and remove no
  longer necessary test for nil
- Change calcSequenceLock to use Ancestor instead of RelativeAncestor
  since it reads more clearly
2017-08-15 15:42:34 -05:00
..
cpuminer all: Remove seelog logger. 2017-06-19 16:46:50 -04:00
log.go all: Remove seelog logger. 2017-06-19 16:46:50 -04:00
mining.go blockchain: Convert to full block index in mem. 2017-08-15 15:42:34 -05:00
mining_test.go mining: Refactor template code into mining package. 2016-10-27 11:48:48 -05:00
policy.go mining+config: modify GBT mining to limit by weight, add witness commitment 2017-08-13 23:17:40 -05:00
policy_test.go mining: Add basic priority calculation tests. 2016-10-27 13:13:37 -05:00
README.md multi: Update markdown files for GFM changes. 2017-05-25 12:06:16 -05:00

mining

Build Status ISC License GoDoc

Overview

This package is currently a work in progress.

Installation and Updating

$ go get -u github.com/btcsuite/btcd/mining

License

Package mining is licensed under the copyfree ISC License.