func New(wf WeightFunc) *HostTree {
	return &HostTree{
		root: &node{
			count: 1,
		},
		weightFn: wf,
		hosts:    make(map[string]*node),
	}
}
New creates a new, empty, HostTree. It takes one argument, a `WeightFunc`,
which is used to determine the weight of a node on Insert.
package hosttree
import (
	"errors"
	"sort"
	"sync"
	"github.com/NebulousLabs/Sia/build"
	"github.com/NebulousLabs/Sia/modules"
	"github.com/NebulousLabs/Sia/types"
	"github.com/NebulousLabs/fastrand"
)
var (
	errHostExists = errors.New("host already exists in the tree")
	errNegativeWeight = errors.New("cannot insert using a negative weight")
	errNilEntry = errors.New("node has a nil entry")
	errNoSuchHost = errors.New("no host with specified public key")
	errWeightTooHeavy = errors.New("requested a too-heavy weight")
)
type (
	WeightFunc func(modules.HostDBEntry) types.Currency
	HostTree struct {
		root *node
		hosts map[string]*node
		weightFn WeightFunc
		mu sync.Mutex
	}
	hostEntry struct {
		modules.HostDBEntry
		weight types.Currency
	}
	node struct {
		parent *node
		left   *node
		right  *node
		count int   
		taken bool  
		weight types.Currency
		entry  *hostEntry
	}
)
func createNode(parent *node, entry *hostEntry) *node {
	return &node{
		parent: parent,
		weight: entry.weight,
		count:  1,
		taken: true,
		entry: entry,
	}
}