// creates a new pool entry using the information in `pi`. // updates `pi` with the result (e.g. fix the Used and Max fields) func (pg *poolGroup) loadFromInfo(pi *PoolInfo) error { pg.Lock() defer pg.Unlock() _, ok := pg.table[pi.Name] if ok { return NameExists } noid, err := noid.NewNoid(pi.Template) if err != nil { return err } p := &pool{ noid: noid, name: pi.Name, closed: pi.Closed, lastMint: pi.LastMint, store: DefaultStore, } // don't technically hold the lock for p, but it hasn't been inserted into pools, yet copyPoolInfo(pi, p) p.empty = pi.Used == pi.Max pg.table[pi.Name] = p pg.names = append(pg.names, pi.Name) return nil }
func getNoid(template string) *noid.Noid { var n noid.Noid n, err := noid.NewNoid(template) if err != nil { fmt.Printf("%s\tInvalid Template: %s\n", template, err.Error()) return nil } return &n }