// Store stores a message in MongoDB and returns its storage ID
165089
func (mongo *MongoDB) Store(m *data.Message) (string, error) {
	err := mongo.Collection.Insert(m)
	if err != nil {
		log.Printf("Error inserting message: %s", err)
		return "", err
	}
	return string(m.ID), nil
}
1312228
func (mg *MailgunImpl) GetStoredMessage(ctx context.Context, url string) (StoredMessage, error) {
	r := newHTTPRequest(url)
	r.setClient(mg.Client())
	r.setBasicAuth(basicAuthUser, mg.APIKey())

	var response StoredMessage
	err := getResponseFromJSON(ctx, r, &response)
	return response, err
}
241264
func (e *Error) Store(err error) {
	e.v.Store(errorHolder{err: err})
}
1024061
func (b *messageBuffer) store(m *message) {
	b.mu.Lock()
	defer b.mu.Unlock()

	if len(b.backlog) == 0 {
		select {
		case b.c <- m:
			return
		default:
		}
	}
	b.backlog = append(b.backlog, m)
}
681745
func (fos *FanOutSink) Store(loc BlockLocation, data []byte) error {
	if fos.closed {
		return errors.WithStack(fmt.Errorf("writing to closed FanOutSink"))
	}

	op := storeOp{
		loc:  loc,
		data: append([]byte{}, data...),
	}

	select {
	case err := <-fos.errs:
		// stop accepting stores
		fos.closed = true

		// cancel all workers
		close(fos.cancelled)

		// immediately return error
		return err
	case fos.stores <- op:
		// we managed to send the store!
	}

	return nil
}
552760
func (s *MemoryUserStore) Store(user *msp.UserData) error {
	s.store[user.ID+"@"+user.MSPID] = user.EnrollmentCertificate
	return nil
}
202579
func (db *DBDataSaver) Store(data *blockdata.BlockData, msgBlock *wire.MsgBlock) error {
	summary := data.ToBlockSummary()
	var err error

	// Store is assumed to be called with a mainchain block
	lastIsValid := msgBlock.Header.VoteBits&1 != 0
	if !lastIsValid {
		// Update the is_valid flag in the blocks table.
		// Need to check whether to invalidate previous block
		lastBlockHash := msgBlock.Header.PrevBlock
		log.Infof("Setting last block %s as INVALID", lastBlockHash)

		// Check for genesis block
		isSecondBlock := lastBlockHash != chainhash.Hash{}
		if isSecondBlock {
			var lastIsMain bool
			lastIsMain, err = db.DB.getMainchainStatus(lastBlockHash.String())
			if err != nil {
				return err
			}
			if lastIsMain {
				lastIsValid := msgBlock.Header.VoteBits&1 != 0
				if !lastIsValid {
					err = db.DB.invalidateBlock(lastBlockHash.String())
					if err != nil {
						return err
					}
				}
			}
		}
	}

	// Store the main chain block data, flagging any other blocks at this height
	// as side chain.
	err = db.DB.StoreBlockSummary(&summary)
	if err != nil {
		return err
	}

	select {
	case db.updateStatusChan <- summary.Height:
	default:
	}

	stakeInfoExtended := data.ToStakeInfoExtended()
	return db.DB.StoreStakeInfoExtended(&stakeInfoExtended)
}
1309694
func (l *MockLedger) Store(block Block) {
	l.blocks = append(l.blocks, block)

	for _, p := range l.consumers {
		blockEvent := l.eventFactory(block, l.sourceURL)
		p <- blockEvent
	}
}
90258
func (s *SortCommand) Store(destination string) *SortCommand {
	s.store = destination
	return s
}
1340122
func (s *NodeState) Store(new NodeState) {
	atomic.StoreInt32((*int32)(s), int32(new))
}
1082319
func (m *resolversMap) Store(key string, value resolver.Resolver) {
	m.data.Store(key, value)
}
1062793
func (m *MemEngine) StoreNode(_ context.Context, key Hash, b []byte) error {
	m.nodes[hex.EncodeToString(key)] = b
	return nil
}
291969
func (s *BlockDataToSummaryStdOut) Store(data *BlockData, _ *wire.MsgBlock) error {
	if s.mtx != nil {
		s.mtx.Lock()
		defer s.mtx.Unlock()
	}

	fmt.Printf("\nBlock %v:\n", data.Header.Height)

	fmt.Printf("  Stake difficulty:                 %9.3f -> %.3f (current -> next block)\n",
		data.CurrentStakeDiff.CurrentStakeDifficulty,
		data.CurrentStakeDiff.NextStakeDifficulty)

	fmt.Printf("  Estimated price in next window:   %9.3f / [%.2f, %.2f] ([min, max])\n",
		data.EstStakeDiff.Expected, data.EstStakeDiff.Min, data.EstStakeDiff.Max)
	fmt.Printf("  Window progress:   %3d / %3d in price window number %v\n",
		data.IdxBlockInWindow, s.sdiffWinSize, data.PriceWindowNum)

	fmt.Printf("  Ticket fees:  %.4f, %.4f, %.4f (mean, median, std), n=%d\n",
		data.FeeInfo.Mean, data.FeeInfo.Median, data.FeeInfo.StdDev,
		data.FeeInfo.Number)

	if data.PoolInfo != nil && data.PoolInfo.Value >= 0 {
		fmt.Printf("  Ticket pool:  %v (size), %.3f (avg. price), %.2f (total DCR locked)\n",
			data.PoolInfo.Size, data.PoolInfo.ValAvg, data.PoolInfo.Value)
	}

	fmt.Printf("  Node connections:  %d\n", data.Connections)

	return nil
}
1324504
func Storage(listener func(*vecty.Event)) *vecty.EventListener {
	return &vecty.EventListener{Name: "storage", Listener: listener}
}
707694
func (m *Map) Store(key, value interface{}) {
	if m.m == nil {
		m.m = make(map[interface{}]interface{})
	}
	m.m[key] = value
}
483057
func (m *dirsMap) Store(key string, value bool) {
	d := m.normalizeKey(key)
	m.data.Store(d, value)
	m.data.Store(strings.TrimPrefix(d, "/"), value)
}
1077186
func (fkvs *FileKeyValueStore) Store(key interface{}, value interface{}) error {
	if key == nil {
		return errors.New("key is nil")
	}
	if value == nil {
		return errors.New("value is nil")
	}
	file, err := fkvs.keySerializer(key)
	if err != nil {
		return err
	}
	valueBytes, err := fkvs.marshaller(value)
	if err != nil {
		return err
	}
	err = os.MkdirAll(filepath.Dir(file), newDirMode)
	if err != nil {
		return err
	}
	return ioutil.WriteFile(file, valueBytes, newFileMode)
}