func (c *dagView) tips() []*blockNode {
	if len(c.nodes) == 0 {
		return nil
	}
	tips := make([]*blockNode, 0, len(c.dagTips))
	for tip := range c.dagTips {
		tips = append(tips, tip)
	}
	sort.Sort(blockSorter(tips))
	return tips
}
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 blockdag
import (
	"github.com/soteria-dag/soterd/chaincfg/chainhash"
	"sort"
	"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 dagView struct {
	mtx      sync.Mutex
	dagTips  map[*blockNode]struct{}
	nodes    [][]*blockNode
}
func newDAGView(tips []*blockNode) *dagView {
	var c dagView
	c.nodes = make([][]*blockNode, 0)
	c.dagTips = make(map[*blockNode]struct{})
	if tips != nil && len(tips) > 0 {
		for _, tip := range tips {
			c.addTip(tip)
		}
	}
	return &c
}
func (c *dagView) genesis() *blockNode {
	if len(c.nodes) == 0 {
		return nil
	}
	return c.nodes[0][0]
}
func (c *dagView) Genesis() *blockNode {
	c.mtx.Lock()
	genesis := c.genesis()
	c.mtx.Unlock()
	return genesis
}