// SwitchBlockOn implements Block.SwitchBlockOn().
424947
func (a *API) SwitchBlockOn(args params.BlockSwitchParams) params.ErrorResult {
	if err := a.checkCanWrite(); err != nil {
		return params.ErrorResult{Error: common.ServerError(err)}
	}

	err := a.access.SwitchBlockOn(state.ParseBlockType(args.Type), args.Message)
	return params.ErrorResult{Error: common.ServerError(err)}
}
1206521
func (p *Process) SwitchGoroutine(gid int) error {
	g, err := proc.FindGoroutine(p, gid)
	if err != nil {
		return err
	}
	if g == nil {
		// user specified -1 and selectedGoroutine is nil
		return nil
	}
	if g.Thread != nil {
		return p.SwitchThread(g.Thread.ThreadID())
	}
	p.selectedGoroutine = g
	return nil
}
530815
func NewOptionBlockObject(value string, text *TextBlockObject) *OptionBlockObject {
	return &OptionBlockObject{
		Text:  text,
		Value: value,
	}
}
925607
func (db *DirBlock) SwapIndirectPtrs(i int, other BlockWithPtrs, otherI int) {
	otherDB, ok := other.(*DirBlock)
	if !ok {
		panic(fmt.Sprintf(
			"SwapIndirectPtrs cannot swap between block types: %T", other))
	}

	db.IPtrs[i], otherDB.IPtrs[otherI] = otherDB.IPtrs[otherI], db.IPtrs[i]
}
877481
func (store *fsBlockStore) AddBlock(block *common.Block) error {
	return store.fileMgr.addBlock(block)
}
638992
func NewBlockEvent(block *cb.Block, sourceURL string) *fab.BlockEvent {
	return &fab.BlockEvent{
		Block:     block,
		SourceURL: sourceURL,
	}
}
186665
func SwitchingProtocols(w http.ResponseWriter, response interface{}) {
	Respond(w, http.StatusSwitchingProtocols, response)
}
269144
func (_m *ChainPuller) PullBlock(seq uint64) *common.Block {
	ret := _m.Called(seq)

	var r0 *common.Block
	if rf, ok := ret.Get(0).(func(uint64) *common.Block); ok {
		r0 = rf(seq)
	} else {
		if ret.Get(0) != nil {
			r0 = ret.Get(0).(*common.Block)
		}
	}

	return r0
}
94334
func (c *Client) SubmitBlock(block *btcutil.Block, options *btcjson.SubmitBlockOptions) error {
	return c.SubmitBlockAsync(block, options).Receive()
}
529507
func (p *ChainMonitor) switchToSideChain(reorgData *txhelpers.ReorgData) (int32, *chainhash.Hash, error) {
	if reorgData == nil || len(reorgData.NewChain) == 0 {
		return 0, nil, fmt.Errorf("no side chain")
	}

	newChain := reorgData.NewChain
	// newChain does not include the common ancestor.
	commonAncestorHeight := int64(reorgData.NewChainHeight) - int64(len(newChain))

	mainTip := p.db.GetBestBlockHeight()
	if mainTip != int64(reorgData.OldChainHeight) {
		log.Warnf("StakeDatabase height is %d, expected %d. Rewinding as "+
			"needed to complete reorg from ancestor at %d", mainTip,
			reorgData.OldChainHeight, commonAncestorHeight)
	}

	// Save blocks from previous side chain that is now the main chain.
	log.Infof("Saving %d new blocks from previous side chain to sqlite.", len(newChain))
	for i := range newChain {
		// Get data by block hash, which requires the stakedb's PoolInfoCache to
		// contain data for the side chain blocks already (guaranteed if stakedb
		// block-connected ntfns are always handled before these).
		blockDataSummary, stakeInfoSummaryExtended := p.collector.CollectAPITypes(&newChain[i])
		if blockDataSummary == nil || stakeInfoSummaryExtended == nil {
			log.Error("Failed to collect data for reorg.")
			continue
		}

		// Before storing data for the new main chain block, set
		// is_mainchain=false for any other block at this height.
		height := int64(blockDataSummary.Height)
		if err := p.db.setHeightToSideChain(height); err != nil {
			log.Errorf("Failed to move blocks at height %d off of main chain: "+
				"%v", height, err)
		}

		// If a block was cached at this height already, it was from the
		// previous mainchain, so remove it.
		if p.db.DB.BlockCache != nil {
			p.db.DB.BlockCache.RemoveCachedBlockByHeight(height)
		}

		// Store this block's summary data and stake info.
		if err := p.db.StoreBlockSummary(blockDataSummary); err != nil {
			log.Errorf("Failed to store block summary data: %v", err)
		}
		if err := p.db.StoreStakeInfoExtended(stakeInfoSummaryExtended); err != nil {
			log.Errorf("Failed to store stake info data: %v", err)
		}
		log.Infof("Promoted block %v (height %d) from side chain to main chain.",
			blockDataSummary.Hash, height)
	}

	// Retrieve height and hash of the best block in the DB.
	hash, height, err := p.db.GetBestBlockHeightHash()
	if err != nil {
		return 0, nil, fmt.Errorf("unable to retrieve best block: %v", err)
	}

	return int32(height), &hash, err
}
1157675
func (c *ConfigLocal) BlockCryptVersion() kbfscrypto.EncryptionVer {
	c.lock.RLock()
	defer c.lock.RUnlock()
	return c.blockCryptVersion
}
783477
func (r *Region) SwitchPeer(storeID uint64) bool {
	for _, p := range r.meta.Peers {
		if p.GetStoreId() == storeID {
			r.peer = p
			return true
		}
	}
	return false
}
791946
func (ctrl Controller) SwitchLocale(w http.ResponseWriter, req *http.Request) {
	utils.SetCookie(http.Cookie{Name: "locale", Value: req.URL.Query().Get("locale")}, &qor.Context{Request: req, Writer: w})
	http.Redirect(w, req, req.Referer(), http.StatusSeeOther)
}
152199
func (jl *jsonLedger) writeBlock(block *cb.Block) {
	name := jl.blockFilename(block.Header.Number)

	fileLock.Lock()
	defer fileLock.Unlock()

	file, err := os.Create(name)
	if err != nil {
		panic(err)
	}
	defer file.Close()

	err = jl.marshaler.Marshal(file, block)
	logger.Debugf("Wrote block %d", block.Header.Number)
	if err != nil {
		logger.Panicf("Error marshalling with block number [%d]: %s", block.Header.Number, err)
	}
}
1064593
func (v *MrbValue) CallBlock(method string, args ...Value) (*MrbValue, error) {
	if len(args) == 0 {
		return nil, fmt.Errorf("args must be non-empty and have a proc at the end")
	}

	n := len(args)
	return v.call(method, args[:n-1], args[n-1])
}
1086844
func (c *Client) ConnectNonBlock(host string, port uint) error {
	return c.Connect(host, port)
}
391952
func (w *Writer) BlocksLen() int {
	n := w.indexBlock.nEntries
	if w.pendingBH.length > 0 {
		// Includes the pending block.
		n++
	}
	return n
}