// AddStore adds the specified store to the store map. func (db *LocalDB) AddStore(s *storage.Store) { db.mu.Lock() defer db.mu.Unlock() if _, ok := db.storeMap[s.Ident.StoreID]; ok { panic(fmt.Sprintf("cannot add store twice to local db: %+v", s.Ident)) } db.storeMap[s.Ident.StoreID] = s // Maintain a slice of ranges ordered by StartKey. db.ranges = append(db.ranges, s.GetRanges()...) sort.Sort(db.ranges) }