func NewAllocator(config Config) *Allocator {
	var participant paxos.Participant
	var alloc *Allocator
	var onUpdate ring.OnUpdate

	if config.IsObserver {
		participant = paxos.NewObserver()
	} else {
		participant = paxos.NewNode(config.OurName, config.OurUID, 0)
	}

	if config.Tracker != nil {
		onUpdate = func(prev []address.Range, curr []address.Range, local bool) {
			if err := config.Tracker.HandleUpdate(prev, curr, local); err != nil {
				alloc.errorf("HandleUpdate failed: %s", err)
			}
		}
	}

	alloc = &Allocator{
		ourName:     config.OurName,
		seed:        config.Seed,
		universe:    config.Universe,
		ring:        ring.New(config.Universe.Range().Start, config.Universe.Range().End, config.OurName, onUpdate),
		owned:       make(map[string]ownedData),
		db:          config.Db,
		paxos:       participant,
		nicknames:   map[mesh.PeerName]string{config.OurName: config.OurNickname},
		isKnownPeer: config.IsKnownPeer,
		quorum:      config.Quorum,
		dead:        make(map[string]time.Time),
		now:         time.Now,
	}

	alloc.pendingClaims = make([]operation, len(config.PreClaims))
	for i, c := range config.PreClaims {
		alloc.pendingClaims[i] = &claim{ident: c.Ident, cidr: c.Cidr}
	}

	return alloc
}
// NewAllocator creates and initialises a new Allocator
NewAllocator creates and initialises a new Allocator
// NewAllocator creates and initialises a new Allocator
func NewAllocator(config Config) *Allocator {
	var participant paxos.Participant
	var alloc *Allocator
	var onUpdate ring.OnUpdate
	if config.IsObserver {
		participant = paxos.NewObserver()
	} else {
		participant = paxos.NewNode(config.OurName, config.OurUID, 0)
	}
	if config.Tracker != nil {
		onUpdate = func(prev []address.Range, curr []address.Range, local bool) {
			if err := config.Tracker.HandleUpdate(prev, curr, local); err != nil {
				alloc.errorf("HandleUpdate failed: %s", err)
			}
		}
	}
	alloc = &Allocator{
		ourName:     config.OurName,
		seed:        config.Seed,
		universe:    config.Universe,
		ring:        ring.New(config.Universe.Range().Start, config.Universe.Range().End, config.OurName, onUpdate),
		owned:       make(map[string]ownedData),
		db:          config.Db,
		paxos:       participant,
		nicknames:   map[mesh.PeerName]string{config.OurName: config.OurNickname},
		isKnownPeer: config.IsKnownPeer,
		quorum:      config.Quorum,
		dead:        make(map[string]time.Time),
		now:         time.Now,
	}
	alloc.pendingClaims = make([]operation, len(config.PreClaims))
	for i, c := range config.PreClaims {
		alloc.pendingClaims[i] = &claim{ident: c.Ident, cidr: c.Cidr}
	}
	return alloc
}
func NewAllocator ( config Config ) * Allocator { var participant paxos . Participant var alloc * Allocator var onUpdate ring . OnUpdate if config . IsObserver { participant = paxos . NewObserver ( ) } else { participant = paxos . NewNode ( config . OurName , config . OurUID , 0 ) } if config . Tracker != nil { onUpdate = func ( prev [ ] address . Range , curr [ ] address . Range , local bool ) { if err := config . Tracker . HandleUpdate ( prev , curr , local ) ; err != nil { alloc . errorf ( " " , err ) } } } alloc = & Allocator { ourName : config . OurName , seed : config . Seed , universe : config . Universe , ring : ring . New ( config . Universe . Range ( ) . Start , config . Universe . Range ( ) . End , config . OurName , onUpdate ) , owned : make ( map [ string ] ownedData ) , db : config . Db , paxos : participant , nicknames : map [ mesh . PeerName ] string { config . OurName : config . OurNickname } , isKnownPeer : config . IsKnownPeer , quorum : config . Quorum , dead : make ( map [ string ] time . Time ) , now : time . Now , } alloc . pendingClaims = make ( [ ] operation , len ( config . PreClaims ) ) for i , c := range config . PreClaims { alloc . pendingClaims [ i ] = & claim { ident : c . Ident , cidr : c . Cidr } } return alloc }
NewAllocator creates and initialises a new Allocator
NewAllocator creates and initialises a new Allocator