code: func (c *chainView) setTip(node *blockNode) {
  	if node == nil {
  		// Keep the backing array around for potential future use.
  		c.nodes = c.nodes[:0]
  		return
  	}
  
  	// Create or resize the slice that will hold the block nodes to the
  	// provided tip height.  When creating the slice, it is created with
  	// some additional capacity for the underlying array as append would do
  	// in order to reduce overhead when extending the chain later.  As long
  	// as the underlying array already has enough capacity, simply expand or
  	// contract the slice accordingly.  The additional capacity is chosen
  	// such that the array should only have to be extended about once a
  	// week.
  	needed := node.height + 1
  	if int32(cap(c.nodes)) < needed {
  		nodes := make([]*blockNode, needed, needed+approxNodesPerWeek)
  		copy(nodes, c.nodes)
  		c.nodes = nodes
  	} else {
  		prevLen := int32(len(c.nodes))
  		c.nodes = c.nodes[0:needed]
  		for i := prevLen; i < needed; i++ {
  			c.nodes[i] = nil
  		}
  	}
  
  	for node != nil && c.nodes[node.height] != node {
  		c.nodes[node.height] = node
  		node = node.parent
  	}
  }
docs: // setTip sets the chain view to use the provided block node as the current tip
  // and ensures the view is consistent by populating it with the nodes obtained
  // by walking backwards all the way to genesis block as necessary.  Further
  // calls will only perform the minimum work needed, so switching between chain
  // tips is efficient.  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 writes).