func (c *chainView) tip() *blockNode {
	if len(c.nodes) == 0 {
		return nil
	}
	return c.nodes[len(c.nodes)-1]
}
tip returns the current tip block node for the chain view.  It will return
nil if there is no tip.  This only differs from the exported version in that
it is up to the caller to ensure the lock is held.

This function MUST be called with the view mutex locked (for reads).
package blockchain
import (
	"sync"
)
const approxNodesPerWeek = 6 * 24 * 7
var log2FloorMasks = []uint32{0xffff0000, 0xff00, 0xf0, 0xc, 0x2}
func fastLog2Floor(n uint32) uint8 {
	rv := uint8(0)
	exponent := uint8(16)
	for i := 0; i < 5; i++ {
		if n&log2FloorMasks[i] != 0 {
			rv += exponent
			n >>= exponent
		}
		exponent >>= 1
	}
	return rv
}
type chainView struct {
	mtx   sync.Mutex
	nodes []*blockNode
}
func newChainView(tip *blockNode) *chainView {
	var c chainView
	c.setTip(tip)
	return &c
}
func (c *chainView) genesis() *blockNode {
	if len(c.nodes) == 0 {
		return nil
	}
	return c.nodes[0]
}
func (c *chainView) Genesis() *blockNode {
	c.mtx.Lock()
	genesis := c.genesis()
	c.mtx.Unlock()
	return genesis
}